gridviz 2.0.37 → 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 +26222 -26220
- package/dist/gridviz.min.js +1 -1
- package/package.json +1 -1
- package/src/Tooltip.js +10 -8
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 -
|
|
104
|
-
.style('top', event.pageY -
|
|
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,21 +141,21 @@ 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
150
|
let maxRight = parentRect.width
|
|
149
151
|
let ttRight = ttNode.offsetLeft + ttNode.clientWidth
|
|
150
152
|
if (ttRight > maxRight) {
|
|
151
|
-
let left = event.pageX -
|
|
153
|
+
let left = event.pageX - parentRect.left - ttNode.clientWidth - this.xOffset
|
|
152
154
|
ttNode.style.left = left + 'px'
|
|
153
155
|
// check if mouse covers tooltip
|
|
154
|
-
if (ttNode.offsetLeft + ttNode.clientWidth +
|
|
156
|
+
if (ttNode.offsetLeft + ttNode.clientWidth + parentRect.left > event.pageX) {
|
|
155
157
|
//move tooltip left so it doesnt cover mouse
|
|
156
|
-
let left2 = event.pageX - (ttNode.clientWidth + this.xOffset +
|
|
158
|
+
let left2 = event.pageX - (ttNode.clientWidth + this.xOffset + parentRect.left)
|
|
157
159
|
ttNode.style.left = left2 + 'px'
|
|
158
160
|
}
|
|
159
161
|
}
|