| 1 |
/* Copyright 2015 Bloomberg Finance L.P. |
| 2 |
* |
| 3 |
* Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 |
* you may not use this file except in compliance with the License. |
| 5 |
* You may obtain a copy of the License at |
| 6 |
* |
| 7 |
* http://www.apache.org/licenses/LICENSE-2.0 |
| 8 |
* |
| 9 |
* Unless required by applicable law or agreed to in writing, software |
| 10 |
* distributed under the License is distributed on an "AS IS" BASIS, |
| 11 |
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 |
* See the License for the specific language governing permissions and |
| 13 |
* limitations under the License. |
| 14 |
*/ |
| 15 |
|
| 16 |
/** |
| 17 |
* A delegate reference for the popper js library |
| 18 |
*/ |
| 19 |
export const ElementReference = (function () { |
| 20 |
function ElementReference(elt) { |
| 21 |
this.elt = elt; |
| 22 |
} |
| 23 |
ElementReference.prototype.getBoundingClientRect = function () { |
| 24 |
return this.elt.getBoundingClientRect(); |
| 25 |
}; |
| 26 |
Object.defineProperty(ElementReference.prototype, 'clientWidth', { |
| 27 |
get: function () { |
| 28 |
return this.elt.clientWidth; |
| 29 |
}, |
| 30 |
enumerable: true, |
| 31 |
configurable: true, |
| 32 |
}); |
| 33 |
Object.defineProperty(ElementReference.prototype, 'clientHeight', { |
| 34 |
get: function () { |
| 35 |
return this.elt.clientHeight; |
| 36 |
}, |
| 37 |
enumerable: true, |
| 38 |
configurable: true, |
| 39 |
}); |
| 40 |
return ElementReference; |
| 41 |
})(); |
| 42 |
|
| 43 |
/** |
| 44 |
* A reference for a specific position. |
| 45 |
*/ |
| 46 |
export const PositionReference = (function () { |
| 47 |
function PositionReference(_a) { |
| 48 |
const x = _a.x, |
| 49 |
y = _a.y, |
| 50 |
width = _a.width, |
| 51 |
height = _a.height; |
| 52 |
this.x = x; |
| 53 |
this.y = y; |
| 54 |
this.width = width; |
| 55 |
this.height = height; |
| 56 |
} |
| 57 |
PositionReference.prototype.getBoundingClientRect = function () { |
| 58 |
const halfwidth = this.width / 2; |
| 59 |
const halfheight = this.height / 2; |
| 60 |
return { |
| 61 |
left: this.x - halfwidth, |
| 62 |
right: this.x + halfwidth, |
| 63 |
top: this.y - halfheight, |
| 64 |
bottom: this.y + halfheight, |
| 65 |
width: this.width, |
| 66 |
height: this.height, |
| 67 |
}; |
| 68 |
}; |
| 69 |
Object.defineProperty(PositionReference.prototype, 'clientWidth', { |
| 70 |
get: function () { |
| 71 |
return this.width; |
| 72 |
}, |
| 73 |
enumerable: true, |
| 74 |
configurable: true, |
| 75 |
}); |
| 76 |
Object.defineProperty(PositionReference.prototype, 'clientHeight', { |
| 77 |
get: function () { |
| 78 |
return this.height; |
| 79 |
}, |
| 80 |
enumerable: true, |
| 81 |
configurable: true, |
| 82 |
}); |
| 83 |
return PositionReference; |
| 84 |
})(); |