three-render-objects 1.33.0 → 1.33.1
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.
|
@@ -9,6 +9,7 @@ import { parseToRgb, opacify } from 'polished';
|
|
|
9
9
|
import { Tween, Easing, Group } from '@tweenjs/tween.js';
|
|
10
10
|
import accessorFn from 'accessor-fn';
|
|
11
11
|
import Kapsule from 'kapsule';
|
|
12
|
+
import Tooltip from 'float-tooltip';
|
|
12
13
|
|
|
13
14
|
function styleInject(css, ref) {
|
|
14
15
|
if (ref === undefined) ref = {};
|
|
@@ -176,10 +177,7 @@ var threeRenderObjects = Kapsule({
|
|
|
176
177
|
onChange: function onChange(_, state) {
|
|
177
178
|
// Reset hover state
|
|
178
179
|
state.hoverObj = null;
|
|
179
|
-
|
|
180
|
-
state.toolTipElem.style.display = 'none';
|
|
181
|
-
state.toolTipElem.innerHTML = '';
|
|
182
|
-
}
|
|
180
|
+
state.tooltip && state.tooltip.content(null);
|
|
183
181
|
},
|
|
184
182
|
triggerUpdate: false
|
|
185
183
|
},
|
|
@@ -249,7 +247,7 @@ var threeRenderObjects = Kapsule({
|
|
|
249
247
|
}
|
|
250
248
|
if (topObject !== state.hoverObj) {
|
|
251
249
|
state.onHover(topObject, state.hoverObj);
|
|
252
|
-
state.
|
|
250
|
+
state.tooltip.content(topObject ? accessorFn(state.tooltipContent)(topObject) || null : null);
|
|
253
251
|
state.hoverObj = topObject;
|
|
254
252
|
}
|
|
255
253
|
}
|
|
@@ -453,9 +451,7 @@ var threeRenderObjects = Kapsule({
|
|
|
453
451
|
state.navInfo.style.display = state.showNavInfo ? null : 'none';
|
|
454
452
|
|
|
455
453
|
// Setup tooltip
|
|
456
|
-
state.
|
|
457
|
-
state.toolTipElem.classList.add('scene-tooltip');
|
|
458
|
-
state.container.appendChild(state.toolTipElem);
|
|
454
|
+
state.tooltip = new Tooltip(state.container);
|
|
459
455
|
|
|
460
456
|
// Capture pointer coords on move or touchstart
|
|
461
457
|
state.pointerPos = new three.Vector2();
|
|
@@ -477,14 +473,6 @@ var threeRenderObjects = Kapsule({
|
|
|
477
473
|
var offset = getOffset(state.container);
|
|
478
474
|
state.pointerPos.x = ev.pageX - offset.left;
|
|
479
475
|
state.pointerPos.y = ev.pageY - offset.top;
|
|
480
|
-
|
|
481
|
-
// Move tooltip
|
|
482
|
-
state.toolTipElem.style.top = "".concat(state.pointerPos.y, "px");
|
|
483
|
-
state.toolTipElem.style.left = "".concat(state.pointerPos.x, "px");
|
|
484
|
-
// adjust horizontal position to not exceed canvas boundaries
|
|
485
|
-
state.toolTipElem.style.transform = "translate(-".concat(state.pointerPos.x / state.width * 100, "%, ").concat(
|
|
486
|
-
// flip to above if near bottom
|
|
487
|
-
state.height - state.pointerPos.y < 100 ? 'calc(-100% - 8px)' : '21px', ")");
|
|
488
476
|
}
|
|
489
477
|
function getOffset(el) {
|
|
490
478
|
var rect = el.getBoundingClientRect(),
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "three-render-objects",
|
|
3
|
-
"version": "1.33.
|
|
3
|
+
"version": "1.33.1",
|
|
4
4
|
"description": "Easy way to render ThreeJS objects with built-in interaction defaults",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -47,6 +47,7 @@
|
|
|
47
47
|
"dependencies": {
|
|
48
48
|
"@tweenjs/tween.js": "18 - 25",
|
|
49
49
|
"accessor-fn": "1",
|
|
50
|
+
"float-tooltip": "1",
|
|
50
51
|
"kapsule": "^1.16",
|
|
51
52
|
"polished": "4"
|
|
52
53
|
},
|