Skip to content

Commit 3b1ae37

Browse files
authored
Add listeners to container document in scrolling monitor (#33)
1 parent 6aa8d0d commit 3b1ae37

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

src/ScrollingMonitor.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ export default class ScrollingMonitor {
2020
this.container.addEventListener('dragover', this.handleEvent);
2121
// touchmove events don't seem to work across siblings, so we unfortunately
2222
// have to attach the listeners to the body
23-
window.document.body.addEventListener('touchmove', this.handleEvent);
23+
this.container.ownerDocument.body.addEventListener('touchmove', this.handleEvent);
2424

2525
this.clearMonitorSubscription = this.dragDropManager
2626
.getMonitor()
@@ -29,7 +29,7 @@ export default class ScrollingMonitor {
2929

3030
stop() {
3131
this.container.removeEventListener('dragover', this.handleEvent);
32-
window.document.body.removeEventListener('touchmove', this.handleEvent);
32+
this.container.ownerDocument.body.removeEventListener('touchmove', this.handleEvent);
3333
this.clearMonitorSubscription();
3434
this.stopScrolling();
3535
}
@@ -54,14 +54,14 @@ export default class ScrollingMonitor {
5454

5555
attach() {
5656
this.attached = true;
57-
window.document.body.addEventListener('dragover', this.updateScrolling);
58-
window.document.body.addEventListener('touchmove', this.updateScrolling);
57+
this.container.ownerDocument.body.addEventListener('dragover', this.updateScrolling);
58+
this.container.ownerDocument.body.addEventListener('touchmove', this.updateScrolling);
5959
}
6060

6161
detach() {
6262
this.attached = false;
63-
window.document.body.removeEventListener('dragover', this.updateScrolling);
64-
window.document.body.removeEventListener('touchmove', this.updateScrolling);
63+
this.container.ownerDocument.body.removeEventListener('dragover', this.updateScrolling);
64+
this.container.ownerDocument.body.removeEventListener('touchmove', this.updateScrolling);
6565
}
6666

6767
// Update scaleX and scaleY every 100ms or so

0 commit comments

Comments
 (0)