gridviz 2.0.36 → 2.0.38
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/gridviz.js +26227 -26223
- package/dist/gridviz.min.js +2 -2
- package/package.json +1 -1
- package/src/Tooltip.js +15 -11
package/package.json
CHANGED
package/src/Tooltip.js
CHANGED
|
@@ -99,11 +99,13 @@ export class Tooltip {
|
|
|
99
99
|
* @param {MouseEvent} event
|
|
100
100
|
*/
|
|
101
101
|
setPosition(event) {
|
|
102
|
+
let parentRect = this.parentElement.getBoundingClientRect()
|
|
103
|
+
|
|
102
104
|
this.tooltip
|
|
103
|
-
.style('left', event.pageX + this.xOffset + 'px')
|
|
104
|
-
.style('top', event.pageY - this.yOffset + 'px')
|
|
105
|
+
.style('left', event.pageX - parentRect.left + this.xOffset + 'px')
|
|
106
|
+
.style('top', event.pageY - parentRect.top - this.yOffset + 'px')
|
|
105
107
|
|
|
106
|
-
this.ensureTooltipInsideContainer(event)
|
|
108
|
+
this.ensureTooltipInsideContainer(event, parentRect)
|
|
107
109
|
}
|
|
108
110
|
|
|
109
111
|
/*
|
|
@@ -139,26 +141,28 @@ export class Tooltip {
|
|
|
139
141
|
* @function ensureTooltipInsideContainer
|
|
140
142
|
* @description Prevents the tooltip from overflowing out of the App container (ensures that the tooltip is inside the gridviz container)
|
|
141
143
|
* @param {MouseEvent} event
|
|
144
|
+
* @param {DOMRect} parentRect
|
|
142
145
|
*/
|
|
143
|
-
ensureTooltipInsideContainer = function (event) {
|
|
146
|
+
ensureTooltipInsideContainer = function (event, parentRect) {
|
|
144
147
|
let ttNode = this.tooltip.node()
|
|
145
|
-
let parentRect = this.parentElement.getBoundingClientRect()
|
|
146
148
|
|
|
147
149
|
//too far right
|
|
148
|
-
|
|
149
|
-
|
|
150
|
+
let maxRight = parentRect.width
|
|
151
|
+
let ttRight = ttNode.offsetLeft + ttNode.clientWidth
|
|
152
|
+
if (ttRight > maxRight) {
|
|
153
|
+
let left = event.pageX - parentRect.left - ttNode.clientWidth - this.xOffset
|
|
150
154
|
ttNode.style.left = left + 'px'
|
|
151
155
|
// check if mouse covers tooltip
|
|
152
|
-
if (ttNode.offsetLeft + ttNode.clientWidth > event.pageX) {
|
|
156
|
+
if (ttNode.offsetLeft + ttNode.clientWidth + parentRect.left > event.pageX) {
|
|
153
157
|
//move tooltip left so it doesnt cover mouse
|
|
154
|
-
let left2 = event.pageX - (ttNode.clientWidth + this.xOffset)
|
|
158
|
+
let left2 = event.pageX - (ttNode.clientWidth + this.xOffset + parentRect.left)
|
|
155
159
|
ttNode.style.left = left2 + 'px'
|
|
156
160
|
}
|
|
157
161
|
}
|
|
158
162
|
|
|
159
163
|
//too far down
|
|
160
|
-
if (
|
|
161
|
-
ttNode.style.top =
|
|
164
|
+
if (ttNode.offsetTop + ttNode.clientHeight > parentRect.height) {
|
|
165
|
+
ttNode.style.top = ttNode.offsetTop - ttNode.clientHeight + 'px'
|
|
162
166
|
}
|
|
163
167
|
}
|
|
164
168
|
}
|