Skip to content

Commit c3523f8

Browse files
committed
refactor code: this.container.ownerDocument.body -> this.eventBody
1 parent 3b1ae37 commit c3523f8

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

src/ScrollingMonitor.js

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ export default class ScrollingMonitor {
66
constructor(dragDropManager, container, options) {
77
this.dragDropManager = dragDropManager;
88
this.container = container;
9+
this.eventBody = container.ownerDocument.body;
910
this.options = options;
1011

1112
this.scaleX = 0;
@@ -20,7 +21,7 @@ export default class ScrollingMonitor {
2021
this.container.addEventListener('dragover', this.handleEvent);
2122
// touchmove events don't seem to work across siblings, so we unfortunately
2223
// have to attach the listeners to the body
23-
this.container.ownerDocument.body.addEventListener('touchmove', this.handleEvent);
24+
this.eventBody.addEventListener('touchmove', this.handleEvent);
2425

2526
this.clearMonitorSubscription = this.dragDropManager
2627
.getMonitor()
@@ -29,7 +30,7 @@ export default class ScrollingMonitor {
2930

3031
stop() {
3132
this.container.removeEventListener('dragover', this.handleEvent);
32-
this.container.ownerDocument.body.removeEventListener('touchmove', this.handleEvent);
33+
this.eventBody.removeEventListener('touchmove', this.handleEvent);
3334
this.clearMonitorSubscription();
3435
this.stopScrolling();
3536
}
@@ -54,14 +55,14 @@ export default class ScrollingMonitor {
5455

5556
attach() {
5657
this.attached = true;
57-
this.container.ownerDocument.body.addEventListener('dragover', this.updateScrolling);
58-
this.container.ownerDocument.body.addEventListener('touchmove', this.updateScrolling);
58+
this.eventBody.addEventListener('dragover', this.updateScrolling);
59+
this.eventBody.addEventListener('touchmove', this.updateScrolling);
5960
}
6061

6162
detach() {
6263
this.attached = false;
63-
this.container.ownerDocument.body.removeEventListener('dragover', this.updateScrolling);
64-
this.container.ownerDocument.body.removeEventListener('touchmove', this.updateScrolling);
64+
this.eventBody.removeEventListener('dragover', this.updateScrolling);
65+
this.eventBody.removeEventListener('touchmove', this.updateScrolling);
6566
}
6667

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

0 commit comments

Comments
 (0)