-
Notifications
You must be signed in to change notification settings - Fork 674
/
Copy pathbase.js
56 lines (39 loc) · 1.71 KB
/
base.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
import { domUtils } from '../../../deps/testcafe-core';
export default class MoveEventSequenceBase {
constructor ({ moveEvent }) {
this.dragAndDropMode = false;
this.dropAllowed = false;
this.moveEvent = moveEvent;
}
setup () {
this.dragAndDropMode = false;
this.dropAllowed = false;
}
leaveElement (/* currentElement, prevElement, commonAncestor, options */) {
}
move (/* element, options */) {
}
enterElement (/* currentElement, prevElement, commonAncestor, options */) {
}
dragAndDrop (/* dragElement, currentElement, prevElement, options, dragDataStore */) {
}
teardown (/* currentElement, eventOptions, prevElement */) {
}
run (currentElement, prevElement, options, dragElement, dragDataStore) {
const elementChanged = currentElement !== prevElement;
const commonAncestor = elementChanged ? domUtils.getCommonAncestor(currentElement, prevElement) : null;
this.setup();
if (elementChanged && !!prevElement)
this.leaveElement(currentElement, prevElement, commonAncestor, options);
if (elementChanged && domUtils.isElementInDocument(currentElement))
this.enterElement(currentElement, prevElement, commonAncestor, options);
this.move(currentElement, options);
this.dragAndDrop(dragElement, currentElement, prevElement, options, dragDataStore);
this.teardown(currentElement, options, prevElement);
const dragAndDropMode = this.dragAndDropMode;
const dropAllowed = this.dropAllowed;
this.dragAndDropMode = false;
this.dropAllowed = false;
return { dragAndDropMode, dropAllowed };
}
}