@vertexvis/doc-viewer 1.0.0-testing.8 → 1.0.0
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/cjs/doc-viewer.cjs.js +1 -1
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/cjs/vertex-document-viewer.cjs.entry.js +60 -6
- package/dist/collection/components/document-viewer/document-viewer.js +88 -4
- package/dist/collection/lib/dom.js +8 -0
- package/dist/collection/lib/interactions/pan-interaction-handler.js +4 -3
- package/dist/components/vertex-document-viewer.js +2 -2
- package/dist/doc-viewer/doc-viewer.esm.js +1 -1
- package/dist/doc-viewer/p-00895e2d.entry.js +25 -0
- package/dist/esm/doc-viewer.js +1 -1
- package/dist/esm/loader.js +1 -1
- package/dist/esm/loader.mjs +1 -1
- package/dist/esm/vertex-document-viewer.entry.js +60 -6
- package/dist/types/components/document-viewer/document-viewer.d.ts +19 -2
- package/dist/types/components.d.ts +8 -0
- package/dist/types/lib/dom.d.ts +1 -0
- package/dist/types/lib/interactions/pan-interaction-handler.d.ts +2 -1
- package/package.json +5 -5
- package/readme.md +1 -1
- package/dist/doc-viewer/p-e5411da0.entry.js +0 -25
|
@@ -21,7 +21,7 @@ var patchBrowser = () => {
|
|
|
21
21
|
|
|
22
22
|
patchBrowser().then(async (options) => {
|
|
23
23
|
await index.globalScripts();
|
|
24
|
-
return index.bootstrapLazy([["vertex-document-viewer.cjs",[[257,"vertex-document-viewer",{"src":[1],"documentId":[513,"document-id"],"provider":[1040],"interactionMode":[1,"interaction-mode"],"documentState":[1040],"layers":[1040],"config":[16],"resizeDebounce":[2,"resize-debounce"],"panByDelta":[64],"zoomTo":[64],"loadPage":[64]},null,{"src":[{"handleSrcChange":0}],"config":[{"handleConfigChange":0}],"interactionMode":[{"handleInteractionModeChange":0}]}]]]], options);
|
|
24
|
+
return index.bootstrapLazy([["vertex-document-viewer.cjs",[[257,"vertex-document-viewer",{"src":[1],"documentId":[513,"document-id"],"provider":[1040],"interactionMode":[1,"interaction-mode"],"documentState":[1040],"layers":[1040],"config":[16],"resizeDebounce":[2,"resize-debounce"],"registerBasicInteractionHandler":[64],"panByDelta":[64],"zoomTo":[64],"loadPage":[64]},null,{"src":[{"handleSrcChange":0}],"config":[{"handleConfigChange":0}],"interactionMode":[{"handleInteractionModeChange":0}]}]]]], options);
|
|
25
25
|
});
|
|
26
26
|
|
|
27
27
|
exports.setNonce = index.setNonce;
|
package/dist/cjs/loader.cjs.js
CHANGED
|
@@ -8,7 +8,7 @@ var index = require('./index-UmtQ5Ckn.js');
|
|
|
8
8
|
const defineCustomElements = async (win, options) => {
|
|
9
9
|
if (typeof window === 'undefined') return undefined;
|
|
10
10
|
await index.globalScripts();
|
|
11
|
-
return index.bootstrapLazy([["vertex-document-viewer.cjs",[[257,"vertex-document-viewer",{"src":[1],"documentId":[513,"document-id"],"provider":[1040],"interactionMode":[1,"interaction-mode"],"documentState":[1040],"layers":[1040],"config":[16],"resizeDebounce":[2,"resize-debounce"],"panByDelta":[64],"zoomTo":[64],"loadPage":[64]},null,{"src":[{"handleSrcChange":0}],"config":[{"handleConfigChange":0}],"interactionMode":[{"handleInteractionModeChange":0}]}]]]], options);
|
|
11
|
+
return index.bootstrapLazy([["vertex-document-viewer.cjs",[[257,"vertex-document-viewer",{"src":[1],"documentId":[513,"document-id"],"provider":[1040],"interactionMode":[1,"interaction-mode"],"documentState":[1040],"layers":[1040],"config":[16],"resizeDebounce":[2,"resize-debounce"],"registerBasicInteractionHandler":[64],"panByDelta":[64],"zoomTo":[64],"loadPage":[64]},null,{"src":[{"handleSrcChange":0}],"config":[{"handleConfigChange":0}],"interactionMode":[{"handleInteractionModeChange":0}]}]]]], options);
|
|
12
12
|
};
|
|
13
13
|
|
|
14
14
|
exports.setNonce = index.setNonce;
|
|
@@ -663,11 +663,20 @@ class DocumentLayersController {
|
|
|
663
663
|
function getElementBoundingClientRect(element) {
|
|
664
664
|
return element.getBoundingClientRect();
|
|
665
665
|
}
|
|
666
|
+
function getAllVertexElementChildren(element) {
|
|
667
|
+
return getAllChildren(element)
|
|
668
|
+
.filter(node => node.nodeName.startsWith('VERTEX-'))
|
|
669
|
+
.reduce((elements, element) => [...elements, element, ...getAllChildren(element)], []);
|
|
670
|
+
}
|
|
671
|
+
function getAllChildren(element) {
|
|
672
|
+
return Array.from(element.querySelectorAll('*'));
|
|
673
|
+
}
|
|
666
674
|
|
|
667
675
|
const DRAG_PIXEL_THRESHOLD = 2;
|
|
668
676
|
class PanInteractionHandler {
|
|
669
|
-
constructor(element, api) {
|
|
677
|
+
constructor(element, hostElement, api) {
|
|
670
678
|
this.element = element;
|
|
679
|
+
this.hostElement = hostElement;
|
|
671
680
|
this.api = api;
|
|
672
681
|
this.isDragging = false;
|
|
673
682
|
this.handlePointerDown = this.handlePointerDown.bind(this);
|
|
@@ -676,11 +685,12 @@ class PanInteractionHandler {
|
|
|
676
685
|
this.handleWheel = this.handleWheel.bind(this);
|
|
677
686
|
this.element.addEventListener('pointerdown', this.handlePointerDown);
|
|
678
687
|
this.element.addEventListener('wheel', this.handleWheel);
|
|
679
|
-
|
|
688
|
+
this.hostElement.addEventListener('wheel', this.handleWheel);
|
|
680
689
|
}
|
|
681
690
|
dispose() {
|
|
682
691
|
this.element.removeEventListener('pointerdown', this.handlePointerDown);
|
|
683
692
|
this.element.removeEventListener('wheel', this.handleWheel);
|
|
693
|
+
this.hostElement.removeEventListener('wheel', this.handleWheel);
|
|
684
694
|
this.removeWindowListeners();
|
|
685
695
|
}
|
|
686
696
|
handleWheel(event) {
|
|
@@ -724,7 +734,6 @@ class PanInteractionHandler {
|
|
|
724
734
|
removeWindowListeners() {
|
|
725
735
|
window.removeEventListener('pointermove', this.handlePointerMove);
|
|
726
736
|
window.removeEventListener('pointerup', this.handlePointerUp);
|
|
727
|
-
window.removeEventListener('wheel', this.handleWheel);
|
|
728
737
|
}
|
|
729
738
|
}
|
|
730
739
|
|
|
@@ -34636,6 +34645,7 @@ const VertexDocumentViewer = class {
|
|
|
34636
34645
|
*/
|
|
34637
34646
|
this.resizeDebounce = 100;
|
|
34638
34647
|
this.dimensions = dimensions.create(0, 0);
|
|
34648
|
+
this.interactionHandlers = [];
|
|
34639
34649
|
}
|
|
34640
34650
|
componentWillLoad() {
|
|
34641
34651
|
this.handleElementResize = this.handleElementResize.bind(this);
|
|
@@ -34643,6 +34653,7 @@ const VertexDocumentViewer = class {
|
|
|
34643
34653
|
this.handlePageLoaded = this.handlePageLoaded.bind(this);
|
|
34644
34654
|
this.handlePageDrawn = this.handlePageDrawn.bind(this);
|
|
34645
34655
|
this.resizeObserver = new ResizeObserver(this.handleElementResize);
|
|
34656
|
+
this.registerSlotChangeListeners();
|
|
34646
34657
|
}
|
|
34647
34658
|
componentShouldUpdate(newValue, oldValue, propName) {
|
|
34648
34659
|
// Ignore updates to the documentState property, as it is only intended to reflect the current state
|
|
@@ -34654,12 +34665,36 @@ const VertexDocumentViewer = class {
|
|
|
34654
34665
|
(_a = this.resizeObserver) === null || _a === void 0 ? void 0 : _a.observe(this.hostEl);
|
|
34655
34666
|
this.updateComponentDimensions();
|
|
34656
34667
|
this.handleSrcChange();
|
|
34668
|
+
this.injectViewerApi();
|
|
34657
34669
|
}
|
|
34658
34670
|
disconnectedCallback() {
|
|
34659
34671
|
var _a;
|
|
34660
34672
|
(_a = this.resizeObserver) === null || _a === void 0 ? void 0 : _a.disconnect();
|
|
34661
34673
|
this.clearCurrentDocument();
|
|
34662
34674
|
}
|
|
34675
|
+
/**
|
|
34676
|
+
* Registers and initializes an interaction handler with the document viewer. Returns a
|
|
34677
|
+
* `Disposable` that should be used to deregister the interaction handler.
|
|
34678
|
+
*
|
|
34679
|
+
* `InteractionHandler`s are used to build custom mouse and touch interactions.
|
|
34680
|
+
*
|
|
34681
|
+
* @param interactionHandler The interaction handler to register.
|
|
34682
|
+
* @returns {Promise<void>} A promise containing the disposable to use to
|
|
34683
|
+
* deregister the handler.
|
|
34684
|
+
*/
|
|
34685
|
+
async registerBasicInteractionHandler(interactionHandler) {
|
|
34686
|
+
this.interactionHandlers.push(interactionHandler);
|
|
34687
|
+
this.initializeInteractionHandler(interactionHandler);
|
|
34688
|
+
return {
|
|
34689
|
+
dispose: () => {
|
|
34690
|
+
const index = this.interactionHandlers.indexOf(interactionHandler);
|
|
34691
|
+
if (index !== -1) {
|
|
34692
|
+
this.interactionHandlers[index].dispose();
|
|
34693
|
+
this.interactionHandlers.splice(index, 1);
|
|
34694
|
+
}
|
|
34695
|
+
},
|
|
34696
|
+
};
|
|
34697
|
+
}
|
|
34663
34698
|
/**
|
|
34664
34699
|
* Pans the currently loaded document by the specified delta.
|
|
34665
34700
|
*
|
|
@@ -34718,9 +34753,9 @@ const VertexDocumentViewer = class {
|
|
|
34718
34753
|
this.updateInteractionHandler();
|
|
34719
34754
|
}
|
|
34720
34755
|
render() {
|
|
34721
|
-
return (index.h(index.Host, { key: '
|
|
34756
|
+
return (index.h(index.Host, { key: 'f1ddf0b4e321bc244a5d757e48f6d71c23caca3c' }, index.h("div", { key: '174c64c537f4b0f1c45fc6543e5b7f54515e4063', ref: ref => (this.viewerContainerElement = ref), class: "viewer-container", onContextMenu: event => event.preventDefault() }, index.h("div", { key: '4c47dadba03b32bde017252a9a8ea7f6e6d323f3', ref: ref => (this.canvasContainerElement = ref), class: classNames('canvas-container', {
|
|
34722
34757
|
'enable-pointer-events ': window.PointerEvent != null,
|
|
34723
|
-
}) }, index.h("canvas", { key: '
|
|
34758
|
+
}) }, index.h("canvas", { key: 'b8697a0a5be45d212b16b3bd4b7b50a70c0a1143', role: "presentation", ref: el => (this.canvasEl = el) })), index.h("slot", { key: 'c9ec02fd4bfaa251d8fc742fc868b0d91ee70618' }))));
|
|
34724
34759
|
}
|
|
34725
34760
|
getDocumentApi() {
|
|
34726
34761
|
if (this.documentApi == null) {
|
|
@@ -34758,7 +34793,7 @@ const VertexDocumentViewer = class {
|
|
|
34758
34793
|
var _a;
|
|
34759
34794
|
(_a = this.panInteractionHandler) === null || _a === void 0 ? void 0 : _a.dispose();
|
|
34760
34795
|
if (this.interactionMode === 'pan' && this.canvasEl != null && this.documentApi != null) {
|
|
34761
|
-
this.panInteractionHandler = new PanInteractionHandler(this.canvasEl, this.documentApi);
|
|
34796
|
+
this.panInteractionHandler = new PanInteractionHandler(this.canvasEl, this.hostEl, this.documentApi);
|
|
34762
34797
|
}
|
|
34763
34798
|
}
|
|
34764
34799
|
updateComponentDimensions(dimensions) {
|
|
@@ -34786,6 +34821,25 @@ const VertexDocumentViewer = class {
|
|
|
34786
34821
|
await ((_a = this.documentApi) === null || _a === void 0 ? void 0 : _a.updateViewport(this.dimensions));
|
|
34787
34822
|
}, this.resizeDebounce);
|
|
34788
34823
|
}
|
|
34824
|
+
initializeInteractionHandler(handler) {
|
|
34825
|
+
if (this.canvasEl == null) {
|
|
34826
|
+
throw new Error('Cannot initialize interaction handler');
|
|
34827
|
+
}
|
|
34828
|
+
handler.initialize(this.canvasEl);
|
|
34829
|
+
}
|
|
34830
|
+
registerSlotChangeListeners() {
|
|
34831
|
+
this.mutationObserver = new MutationObserver(_ => this.injectViewerApi());
|
|
34832
|
+
this.mutationObserver.observe(this.hostEl, {
|
|
34833
|
+
childList: true,
|
|
34834
|
+
subtree: true,
|
|
34835
|
+
});
|
|
34836
|
+
}
|
|
34837
|
+
injectViewerApi() {
|
|
34838
|
+
getAllVertexElementChildren(this.hostEl).forEach(node => {
|
|
34839
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
34840
|
+
node.viewer = this.hostEl;
|
|
34841
|
+
});
|
|
34842
|
+
}
|
|
34789
34843
|
get hostEl() { return index.getElement(this); }
|
|
34790
34844
|
static get watchers() { return {
|
|
34791
34845
|
"src": [{
|
|
@@ -6,7 +6,7 @@ import { h, Host } from "@stencil/core";
|
|
|
6
6
|
import { Dimensions } from "@vertexvis/geometry";
|
|
7
7
|
import classNames from "classnames";
|
|
8
8
|
import { DocumentLayersController } from "../../lib/document/layers/controller";
|
|
9
|
-
import { getElementBoundingClientRect } from "../../lib/dom";
|
|
9
|
+
import { getAllVertexElementChildren, getElementBoundingClientRect } from "../../lib/dom";
|
|
10
10
|
import { PanInteractionHandler } from "../../lib/interactions/pan-interaction-handler";
|
|
11
11
|
import { PdfJsProvider } from "../../lib/pdf/pdfjs-provider";
|
|
12
12
|
export class VertexDocumentViewer {
|
|
@@ -27,6 +27,7 @@ export class VertexDocumentViewer {
|
|
|
27
27
|
*/
|
|
28
28
|
this.resizeDebounce = 100;
|
|
29
29
|
this.dimensions = Dimensions.create(0, 0);
|
|
30
|
+
this.interactionHandlers = [];
|
|
30
31
|
}
|
|
31
32
|
componentWillLoad() {
|
|
32
33
|
this.handleElementResize = this.handleElementResize.bind(this);
|
|
@@ -34,6 +35,7 @@ export class VertexDocumentViewer {
|
|
|
34
35
|
this.handlePageLoaded = this.handlePageLoaded.bind(this);
|
|
35
36
|
this.handlePageDrawn = this.handlePageDrawn.bind(this);
|
|
36
37
|
this.resizeObserver = new ResizeObserver(this.handleElementResize);
|
|
38
|
+
this.registerSlotChangeListeners();
|
|
37
39
|
}
|
|
38
40
|
componentShouldUpdate(newValue, oldValue, propName) {
|
|
39
41
|
// Ignore updates to the documentState property, as it is only intended to reflect the current state
|
|
@@ -45,12 +47,36 @@ export class VertexDocumentViewer {
|
|
|
45
47
|
(_a = this.resizeObserver) === null || _a === void 0 ? void 0 : _a.observe(this.hostEl);
|
|
46
48
|
this.updateComponentDimensions();
|
|
47
49
|
this.handleSrcChange();
|
|
50
|
+
this.injectViewerApi();
|
|
48
51
|
}
|
|
49
52
|
disconnectedCallback() {
|
|
50
53
|
var _a;
|
|
51
54
|
(_a = this.resizeObserver) === null || _a === void 0 ? void 0 : _a.disconnect();
|
|
52
55
|
this.clearCurrentDocument();
|
|
53
56
|
}
|
|
57
|
+
/**
|
|
58
|
+
* Registers and initializes an interaction handler with the document viewer. Returns a
|
|
59
|
+
* `Disposable` that should be used to deregister the interaction handler.
|
|
60
|
+
*
|
|
61
|
+
* `InteractionHandler`s are used to build custom mouse and touch interactions.
|
|
62
|
+
*
|
|
63
|
+
* @param interactionHandler The interaction handler to register.
|
|
64
|
+
* @returns {Promise<void>} A promise containing the disposable to use to
|
|
65
|
+
* deregister the handler.
|
|
66
|
+
*/
|
|
67
|
+
async registerBasicInteractionHandler(interactionHandler) {
|
|
68
|
+
this.interactionHandlers.push(interactionHandler);
|
|
69
|
+
this.initializeInteractionHandler(interactionHandler);
|
|
70
|
+
return {
|
|
71
|
+
dispose: () => {
|
|
72
|
+
const index = this.interactionHandlers.indexOf(interactionHandler);
|
|
73
|
+
if (index !== -1) {
|
|
74
|
+
this.interactionHandlers[index].dispose();
|
|
75
|
+
this.interactionHandlers.splice(index, 1);
|
|
76
|
+
}
|
|
77
|
+
},
|
|
78
|
+
};
|
|
79
|
+
}
|
|
54
80
|
/**
|
|
55
81
|
* Pans the currently loaded document by the specified delta.
|
|
56
82
|
*
|
|
@@ -109,9 +135,9 @@ export class VertexDocumentViewer {
|
|
|
109
135
|
this.updateInteractionHandler();
|
|
110
136
|
}
|
|
111
137
|
render() {
|
|
112
|
-
return (h(Host, { key: '
|
|
138
|
+
return (h(Host, { key: 'f1ddf0b4e321bc244a5d757e48f6d71c23caca3c' }, h("div", { key: '174c64c537f4b0f1c45fc6543e5b7f54515e4063', ref: ref => (this.viewerContainerElement = ref), class: "viewer-container", onContextMenu: event => event.preventDefault() }, h("div", { key: '4c47dadba03b32bde017252a9a8ea7f6e6d323f3', ref: ref => (this.canvasContainerElement = ref), class: classNames('canvas-container', {
|
|
113
139
|
'enable-pointer-events ': window.PointerEvent != null,
|
|
114
|
-
}) }, h("canvas", { key: '
|
|
140
|
+
}) }, h("canvas", { key: 'b8697a0a5be45d212b16b3bd4b7b50a70c0a1143', role: "presentation", ref: el => (this.canvasEl = el) })), h("slot", { key: 'c9ec02fd4bfaa251d8fc742fc868b0d91ee70618' }))));
|
|
115
141
|
}
|
|
116
142
|
getDocumentApi() {
|
|
117
143
|
if (this.documentApi == null) {
|
|
@@ -149,7 +175,7 @@ export class VertexDocumentViewer {
|
|
|
149
175
|
var _a;
|
|
150
176
|
(_a = this.panInteractionHandler) === null || _a === void 0 ? void 0 : _a.dispose();
|
|
151
177
|
if (this.interactionMode === 'pan' && this.canvasEl != null && this.documentApi != null) {
|
|
152
|
-
this.panInteractionHandler = new PanInteractionHandler(this.canvasEl, this.documentApi);
|
|
178
|
+
this.panInteractionHandler = new PanInteractionHandler(this.canvasEl, this.hostEl, this.documentApi);
|
|
153
179
|
}
|
|
154
180
|
}
|
|
155
181
|
updateComponentDimensions(dimensions) {
|
|
@@ -177,6 +203,25 @@ export class VertexDocumentViewer {
|
|
|
177
203
|
await ((_a = this.documentApi) === null || _a === void 0 ? void 0 : _a.updateViewport(this.dimensions));
|
|
178
204
|
}, this.resizeDebounce);
|
|
179
205
|
}
|
|
206
|
+
initializeInteractionHandler(handler) {
|
|
207
|
+
if (this.canvasEl == null) {
|
|
208
|
+
throw new Error('Cannot initialize interaction handler');
|
|
209
|
+
}
|
|
210
|
+
handler.initialize(this.canvasEl);
|
|
211
|
+
}
|
|
212
|
+
registerSlotChangeListeners() {
|
|
213
|
+
this.mutationObserver = new MutationObserver(_ => this.injectViewerApi());
|
|
214
|
+
this.mutationObserver.observe(this.hostEl, {
|
|
215
|
+
childList: true,
|
|
216
|
+
subtree: true,
|
|
217
|
+
});
|
|
218
|
+
}
|
|
219
|
+
injectViewerApi() {
|
|
220
|
+
getAllVertexElementChildren(this.hostEl).forEach(node => {
|
|
221
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
222
|
+
node.viewer = this.hostEl;
|
|
223
|
+
});
|
|
224
|
+
}
|
|
180
225
|
static get is() { return "vertex-document-viewer"; }
|
|
181
226
|
static get encapsulation() { return "shadow"; }
|
|
182
227
|
static get originalStyleUrls() {
|
|
@@ -460,6 +505,45 @@ export class VertexDocumentViewer {
|
|
|
460
505
|
}
|
|
461
506
|
static get methods() {
|
|
462
507
|
return {
|
|
508
|
+
"registerBasicInteractionHandler": {
|
|
509
|
+
"complexType": {
|
|
510
|
+
"signature": "(interactionHandler: BasicInteractionHandler) => Promise<Disposable>",
|
|
511
|
+
"parameters": [{
|
|
512
|
+
"name": "interactionHandler",
|
|
513
|
+
"type": "BasicInteractionHandler",
|
|
514
|
+
"docs": "The interaction handler to register."
|
|
515
|
+
}],
|
|
516
|
+
"references": {
|
|
517
|
+
"Promise": {
|
|
518
|
+
"location": "global",
|
|
519
|
+
"id": "global::Promise"
|
|
520
|
+
},
|
|
521
|
+
"Disposable": {
|
|
522
|
+
"location": "import",
|
|
523
|
+
"path": "@vertexvis/utils",
|
|
524
|
+
"id": "../utils/dist/index.d.ts::Disposable",
|
|
525
|
+
"referenceLocation": "Disposable"
|
|
526
|
+
},
|
|
527
|
+
"BasicInteractionHandler": {
|
|
528
|
+
"location": "import",
|
|
529
|
+
"path": "@vertexvis/utils",
|
|
530
|
+
"id": "../utils/dist/index.d.ts::BasicInteractionHandler",
|
|
531
|
+
"referenceLocation": "BasicInteractionHandler"
|
|
532
|
+
}
|
|
533
|
+
},
|
|
534
|
+
"return": "Promise<Disposable>"
|
|
535
|
+
},
|
|
536
|
+
"docs": {
|
|
537
|
+
"text": "Registers and initializes an interaction handler with the document viewer. Returns a\n`Disposable` that should be used to deregister the interaction handler.\n\n`InteractionHandler`s are used to build custom mouse and touch interactions.",
|
|
538
|
+
"tags": [{
|
|
539
|
+
"name": "param",
|
|
540
|
+
"text": "interactionHandler The interaction handler to register."
|
|
541
|
+
}, {
|
|
542
|
+
"name": "returns",
|
|
543
|
+
"text": "A promise containing the disposable to use to\nderegister the handler."
|
|
544
|
+
}]
|
|
545
|
+
}
|
|
546
|
+
},
|
|
463
547
|
"panByDelta": {
|
|
464
548
|
"complexType": {
|
|
465
549
|
"signature": "(delta: Point.Point) => Promise<void>",
|
|
@@ -4,3 +4,11 @@
|
|
|
4
4
|
export function getElementBoundingClientRect(element) {
|
|
5
5
|
return element.getBoundingClientRect();
|
|
6
6
|
}
|
|
7
|
+
export function getAllVertexElementChildren(element) {
|
|
8
|
+
return getAllChildren(element)
|
|
9
|
+
.filter(node => node.nodeName.startsWith('VERTEX-'))
|
|
10
|
+
.reduce((elements, element) => [...elements, element, ...getAllChildren(element)], []);
|
|
11
|
+
}
|
|
12
|
+
function getAllChildren(element) {
|
|
13
|
+
return Array.from(element.querySelectorAll('*'));
|
|
14
|
+
}
|
|
@@ -4,8 +4,9 @@
|
|
|
4
4
|
import { Point } from "@vertexvis/geometry";
|
|
5
5
|
const DRAG_PIXEL_THRESHOLD = 2;
|
|
6
6
|
export class PanInteractionHandler {
|
|
7
|
-
constructor(element, api) {
|
|
7
|
+
constructor(element, hostElement, api) {
|
|
8
8
|
this.element = element;
|
|
9
|
+
this.hostElement = hostElement;
|
|
9
10
|
this.api = api;
|
|
10
11
|
this.isDragging = false;
|
|
11
12
|
this.handlePointerDown = this.handlePointerDown.bind(this);
|
|
@@ -14,11 +15,12 @@ export class PanInteractionHandler {
|
|
|
14
15
|
this.handleWheel = this.handleWheel.bind(this);
|
|
15
16
|
this.element.addEventListener('pointerdown', this.handlePointerDown);
|
|
16
17
|
this.element.addEventListener('wheel', this.handleWheel);
|
|
17
|
-
|
|
18
|
+
this.hostElement.addEventListener('wheel', this.handleWheel);
|
|
18
19
|
}
|
|
19
20
|
dispose() {
|
|
20
21
|
this.element.removeEventListener('pointerdown', this.handlePointerDown);
|
|
21
22
|
this.element.removeEventListener('wheel', this.handleWheel);
|
|
23
|
+
this.hostElement.removeEventListener('wheel', this.handleWheel);
|
|
22
24
|
this.removeWindowListeners();
|
|
23
25
|
}
|
|
24
26
|
handleWheel(event) {
|
|
@@ -62,6 +64,5 @@ export class PanInteractionHandler {
|
|
|
62
64
|
removeWindowListeners() {
|
|
63
65
|
window.removeEventListener('pointermove', this.handlePointerMove);
|
|
64
66
|
window.removeEventListener('pointerup', this.handlePointerUp);
|
|
65
|
-
window.removeEventListener('wheel', this.handleWheel);
|
|
66
67
|
}
|
|
67
68
|
}
|