jqtree 1.5.2 → 1.6.2

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.
Files changed (174) hide show
  1. package/.eslintrc +1 -0
  2. package/.github/workflows/ci.yml +54 -0
  3. package/.github/workflows/codeql-analysis.yml +28 -0
  4. package/README.md +1 -1
  5. package/_config.yml +1 -1
  6. package/_entries/10_changelog.md +20 -0
  7. package/_entries/{36_showemptynode.md → 36_showemptyfolder.md} +5 -5
  8. package/_entries/38_start_dnd_delay.md +13 -0
  9. package/_entries/{38_tabindex.md → 39_tabindex.md} +0 -0
  10. package/_entries/{39_usecontextmenu.md → 40_usecontextmenu.md} +0 -0
  11. package/_entries/{40_functions.md → 41_functions.md} +0 -0
  12. package/_entries/{41_addparentnode.md → 42_addparentnode.md} +0 -0
  13. package/_entries/{42_addnodeafter.md → 43_addnodeafter.md} +0 -0
  14. package/_entries/{43_addnodebefore.md → 44_addnodebefore.md} +0 -0
  15. package/_entries/{44_appendnode.md → 45_appendnode.md} +0 -0
  16. package/_entries/{45_closenode.md → 46_closenode.md} +0 -0
  17. package/_entries/{46_destroy.md → 47_destroy.md} +0 -0
  18. package/_entries/{47_getnodebycallback.md → 48_getnodebycallback.md} +0 -0
  19. package/_entries/{48_getnodebyid.md → 49_getnodebyid.md} +0 -0
  20. package/_entries/{49_getnodebyhtmlelement.md → 50_getnodebyhtmlelement.md} +0 -0
  21. package/_entries/{50_getselectednode.md → 51_getselectednode.md} +0 -0
  22. package/_entries/{51_getstate.md → 52_getstate.md} +0 -0
  23. package/_entries/{52_gettree.md → 53_gettree.md} +0 -0
  24. package/_entries/{53_isdragging.md → 54_isdragging.md} +0 -0
  25. package/_entries/{54_loaddata.md → 55_loaddata.md} +0 -0
  26. package/_entries/{55_loaddatafromurl.md → 56_loaddatafromurl.md} +0 -0
  27. package/_entries/{56_movedown.md → 57_movedown.md} +0 -0
  28. package/_entries/{57_movenode.md → 58_movenode.md} +0 -0
  29. package/_entries/{58_moveup.md → 59_moveup.md} +0 -0
  30. package/_entries/{59_opennode.md → 60_opennode.md} +0 -0
  31. package/_entries/{60_prependnode.md → 61_prependnode.md} +0 -0
  32. package/_entries/62_refresh.md +12 -0
  33. package/_entries/{61_reload.md → 63_reload.md} +0 -0
  34. package/_entries/{62_removenode.md → 64_removenode.md} +0 -0
  35. package/_entries/{63_selectnode.md → 65_selectnode.md} +0 -0
  36. package/_entries/{64_scrolltonode.md → 66_scrolltonode.md} +0 -0
  37. package/_entries/{65_setoption.md → 67_setoption.md} +0 -0
  38. package/_entries/{66_setstate.md → 68_setstate.md} +0 -0
  39. package/_entries/{67_toggle.md → 69_toggle.md} +0 -0
  40. package/_entries/{68_tojson.md → 70_tojson.md} +0 -0
  41. package/_entries/{69_updatenode.md → 71_updatenode.md} +0 -0
  42. package/_entries/{70_events.md → 72_events.md} +0 -0
  43. package/_entries/{71_tree-click.md → 73_tree-click.md} +0 -0
  44. package/_entries/{72_tree-close.md → 74_tree-close.md} +0 -0
  45. package/_entries/{73_tree-contextmenu.md → 75_tree-contextmenu.md} +0 -0
  46. package/_entries/{74_tree-dblclick.md → 76_tree-dblclick.md} +0 -0
  47. package/_entries/{75_tree-init.md → 77_tree-init.md} +0 -0
  48. package/_entries/{76_tree-load-data.md → 78_tree-load-data.md} +0 -0
  49. package/_entries/{77_tree-loading-data.md → 79_tree-loading-data.md} +0 -0
  50. package/_entries/{78_tree-move.md → 80_tree-move.md} +0 -0
  51. package/_entries/{79_tree-refresh.md → 81_tree-refresh.md} +0 -0
  52. package/_entries/{80_tree-open.md → 82_tree-open.md} +0 -0
  53. package/_entries/{81_tree-select.md → 83_tree-select.md} +0 -0
  54. package/_entries/{82_multiple-selection.md → 84_multiple-selection.md} +0 -0
  55. package/_entries/{83_add-to-selection.md → 85_add-to-selection.md} +0 -0
  56. package/_entries/{84_get-selected-nodes.md → 86_get-selected-nodes.md} +0 -0
  57. package/_entries/{85_is-node-selected.md → 87_is-node-selected.md} +0 -0
  58. package/_entries/{86_remove-from-selection.md → 88_remove-from-selection.md} +0 -0
  59. package/_entries/{87_node-functions.md → 89_node-functions.md} +0 -0
  60. package/_entries/{88_children.md → 90_children.md} +0 -0
  61. package/_entries/{89_getdata.md → 91_getdata.md} +0 -0
  62. package/_entries/{90_getlevel.md → 92_getlevel.md} +0 -0
  63. package/_entries/{91_getnextnode.md → 93_getnextnode.md} +0 -0
  64. package/_entries/{92_getnextsibling.md → 94_getnextsibling.md} +0 -0
  65. package/_entries/{93_getpreviousnode.md → 95_getpreviousnode.md} +0 -0
  66. package/_entries/{94_getprevioussibling.md → 96_getprevioussibling.md} +0 -0
  67. package/_entries/{95_parent.md → 97_parent.md} +0 -0
  68. package/_examples/13_drag_outside.html +2 -1
  69. package/_examples/14_filter.html +113 -0
  70. package/_layouts/base.html +1 -23
  71. package/babel.config.json +11 -0
  72. package/babel.coverage.config.json +4 -0
  73. package/bower.json +1 -1
  74. package/jest-browser.config.js +0 -3
  75. package/jest-jsdom.config.js +1 -2
  76. package/jqtree.css +4 -1
  77. package/jqtree.postcss +3 -0
  78. package/lib/dataLoader.js +146 -98
  79. package/lib/dragAndDropHandler.js +668 -470
  80. package/lib/elementsRenderer.js +282 -197
  81. package/lib/jqtreeOptions.js +1 -2
  82. package/lib/keyHandler.js +134 -87
  83. package/lib/mouse.widget.js +288 -165
  84. package/lib/node.js +693 -505
  85. package/lib/nodeElement.js +329 -205
  86. package/lib/playwright/playwright.test.js +216 -189
  87. package/lib/playwright/testUtil.js +437 -192
  88. package/lib/playwright/visualRegression.js +183 -117
  89. package/lib/saveStateHandler.js +311 -204
  90. package/lib/scrollHandler.js +293 -199
  91. package/lib/selectNodeHandler.js +140 -105
  92. package/lib/simple.widget.js +184 -109
  93. package/lib/test/global.d.js +3 -0
  94. package/lib/test/jqTree/create.test.js +44 -40
  95. package/lib/test/jqTree/events.test.js +185 -138
  96. package/lib/test/jqTree/keyboard.test.js +216 -199
  97. package/lib/test/jqTree/loadOnDemand.test.js +233 -157
  98. package/lib/test/jqTree/methods.test.js +1269 -1000
  99. package/lib/test/jqTree/options.test.js +467 -398
  100. package/lib/test/node.test.js +1036 -873
  101. package/lib/test/nodeUtil.test.js +21 -20
  102. package/lib/test/support/exampleData.js +35 -23
  103. package/lib/test/support/jqTreeMatchers.js +72 -54
  104. package/lib/test/support/matchers.d.js +1 -0
  105. package/lib/test/support/setupTests.js +9 -3
  106. package/lib/test/support/testUtil.js +38 -15
  107. package/lib/test/support/treeStructure.js +41 -32
  108. package/lib/test/util.test.js +21 -20
  109. package/lib/tree.jquery.d.js +1 -0
  110. package/lib/tree.jquery.js +1264 -883
  111. package/lib/types.js +1 -2
  112. package/lib/typings.d.js +2 -0
  113. package/lib/util.js +21 -7
  114. package/lib/version.js +8 -3
  115. package/package.json +43 -36
  116. package/production +4 -4
  117. package/rollup.config.js +16 -11
  118. package/src/dataLoader.ts +6 -6
  119. package/src/dragAndDropHandler.ts +0 -4
  120. package/src/elementsRenderer.ts +4 -0
  121. package/src/jqtreeOptions.ts +33 -32
  122. package/src/mouse.widget.ts +58 -29
  123. package/src/node.ts +32 -46
  124. package/src/nodeElement.ts +17 -9
  125. package/src/playwright/.eslintrc +5 -0
  126. package/src/playwright/playwright.test.ts +30 -30
  127. package/src/playwright/testUtil.ts +36 -37
  128. package/src/saveStateHandler.ts +11 -6
  129. package/src/selectNodeHandler.ts +14 -21
  130. package/src/simple.widget.ts +1 -1
  131. package/src/test/.eslintrc +4 -0
  132. package/src/test/jqTree/create.test.ts +0 -1
  133. package/src/test/jqTree/events.test.ts +12 -13
  134. package/src/test/jqTree/keyboard.test.ts +0 -1
  135. package/src/test/jqTree/loadOnDemand.test.ts +46 -1
  136. package/src/test/jqTree/methods.test.ts +67 -18
  137. package/src/test/jqTree/options.test.ts +5 -6
  138. package/src/test/node.test.ts +2 -2
  139. package/src/test/support/jqTreeMatchers.ts +8 -9
  140. package/src/test/support/matchers.d.ts +2 -4
  141. package/src/test/support/setupTests.ts +2 -1
  142. package/src/tree.jquery.d.ts +19 -13
  143. package/src/tree.jquery.ts +63 -57
  144. package/src/version.ts +1 -1
  145. package/static/bower.json +3 -3
  146. package/static/bower_components/fontawesome/css/all.min.css +2 -2
  147. package/static/bower_components/fontawesome/webfonts/fa-brands-400.eot +0 -0
  148. package/static/bower_components/fontawesome/webfonts/fa-brands-400.svg +774 -627
  149. package/static/bower_components/fontawesome/webfonts/fa-brands-400.ttf +0 -0
  150. package/static/bower_components/fontawesome/webfonts/fa-brands-400.woff +0 -0
  151. package/static/bower_components/fontawesome/webfonts/fa-brands-400.woff2 +0 -0
  152. package/static/bower_components/fontawesome/webfonts/fa-regular-400.eot +0 -0
  153. package/static/bower_components/fontawesome/webfonts/fa-regular-400.svg +93 -95
  154. package/static/bower_components/fontawesome/webfonts/fa-regular-400.ttf +0 -0
  155. package/static/bower_components/fontawesome/webfonts/fa-regular-400.woff +0 -0
  156. package/static/bower_components/fontawesome/webfonts/fa-regular-400.woff2 +0 -0
  157. package/static/bower_components/fontawesome/webfonts/fa-solid-900.eot +0 -0
  158. package/static/bower_components/fontawesome/webfonts/fa-solid-900.svg +1164 -1074
  159. package/static/bower_components/fontawesome/webfonts/fa-solid-900.ttf +0 -0
  160. package/static/bower_components/fontawesome/webfonts/fa-solid-900.woff +0 -0
  161. package/static/bower_components/fontawesome/webfonts/fa-solid-900.woff2 +0 -0
  162. package/static/bower_components/jquery/dist/jquery.js +118 -109
  163. package/static/bower_components/jquery/dist/jquery.min.js +2 -2
  164. package/static/bower_components/jquery-mockjax/dist/jquery.mockjax.js +15 -9
  165. package/static/example.css +13 -0
  166. package/static/example.postcss +13 -0
  167. package/static/example_data.js +33 -36
  168. package/static/examples/filter.js +63 -0
  169. package/tree.jquery.debug.js +4809 -3305
  170. package/tree.jquery.debug.js.map +1 -1
  171. package/tree.jquery.js +3 -3
  172. package/tree.jquery.js.map +1 -1
  173. package/tsconfig.json +1 -0
  174. package/.travis.yml +0 -18
@@ -1,183 +1,306 @@
1
1
  "use strict";
2
- var __extends = (this && this.__extends) || (function () {
3
- var extendStatics = function (d, b) {
4
- extendStatics = Object.setPrototypeOf ||
5
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6
- function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
7
- return extendStatics(d, b);
8
- };
9
- return function (d, b) {
10
- extendStatics(d, b);
11
- function __() { this.constructor = d; }
12
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
13
- };
14
- })();
15
- exports.__esModule = true;
16
- /*
17
- This widget does the same a the mouse widget in jqueryui.
18
- */
19
- var simple_widget_1 = require("./simple.widget");
20
- var getPositionInfoFromMouseEvent = function (e) { return ({
2
+
3
+ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
4
+
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports["default"] = void 0;
9
+
10
+ var _simple = _interopRequireDefault(require("./simple.widget"));
11
+
12
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
13
+
14
+ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
15
+
16
+ function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
17
+
18
+ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
19
+
20
+ function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } Object.defineProperty(subClass, "prototype", { value: Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }), writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
21
+
22
+ function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
23
+
24
+ function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
25
+
26
+ function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
27
+
28
+ function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
29
+
30
+ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
31
+
32
+ function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
33
+
34
+ function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
35
+
36
+ var getPositionInfoFromMouseEvent = function getPositionInfoFromMouseEvent(e) {
37
+ return {
21
38
  pageX: e.pageX,
22
39
  pageY: e.pageY,
23
40
  target: e.target,
24
41
  originalEvent: e
25
- }); };
26
- var getPositionInfoFromTouch = function (touch, e) { return ({
42
+ };
43
+ };
44
+
45
+ var getPositionInfoFromTouch = function getPositionInfoFromTouch(touch, e) {
46
+ return {
27
47
  pageX: touch.pageX,
28
48
  pageY: touch.pageY,
29
49
  target: touch.target,
30
50
  originalEvent: e
31
- }); };
32
- var MouseWidget = /** @class */ (function (_super) {
33
- __extends(MouseWidget, _super);
34
- function MouseWidget() {
35
- var _this = _super !== null && _super.apply(this, arguments) || this;
36
- _this.mouseDown = function (e) {
37
- // Left mouse button?
38
- if (e.button !== 0) {
39
- return;
40
- }
41
- var result = _this.handleMouseDown(getPositionInfoFromMouseEvent(e));
42
- if (result && e.cancelable) {
43
- e.preventDefault();
44
- }
45
- };
46
- _this.mouseMove = function (e) {
47
- _this.handleMouseMove(e, getPositionInfoFromMouseEvent(e));
48
- };
49
- _this.mouseUp = function (e) {
50
- _this.handleMouseUp(getPositionInfoFromMouseEvent(e));
51
- };
52
- _this.touchStart = function (e) {
53
- if (!e) {
54
- return;
55
- }
56
- if (e.touches.length > 1) {
57
- return;
58
- }
59
- var touch = e.changedTouches[0];
60
- _this.handleMouseDown(getPositionInfoFromTouch(touch, e));
61
- };
62
- _this.touchMove = function (e) {
63
- if (!e) {
64
- return;
65
- }
66
- if (e.touches.length > 1) {
67
- return;
68
- }
69
- var touch = e.changedTouches[0];
70
- _this.handleMouseMove(e, getPositionInfoFromTouch(touch, e));
71
- };
72
- _this.touchEnd = function (e) {
73
- if (!e) {
74
- return;
75
- }
76
- if (e.touches.length > 1) {
77
- return;
78
- }
79
- var touch = e.changedTouches[0];
80
- _this.handleMouseUp(getPositionInfoFromTouch(touch, e));
81
- };
82
- return _this;
51
+ };
52
+ };
53
+
54
+ var MouseWidget = /*#__PURE__*/function (_SimpleWidget) {
55
+ _inherits(MouseWidget, _SimpleWidget);
56
+
57
+ var _super = _createSuper(MouseWidget);
58
+
59
+ function MouseWidget() {
60
+ var _this;
61
+
62
+ _classCallCheck(this, MouseWidget);
63
+
64
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
65
+ args[_key] = arguments[_key];
83
66
  }
84
- MouseWidget.prototype.setMouseDelay = function (mouseDelay) {
85
- this.mouseDelay = mouseDelay;
86
- };
87
- MouseWidget.prototype.init = function () {
88
- var element = this.$el.get(0);
67
+
68
+ _this = _super.call.apply(_super, [this].concat(args));
69
+
70
+ _defineProperty(_assertThisInitialized(_this), "isMouseStarted", void 0);
71
+
72
+ _defineProperty(_assertThisInitialized(_this), "mouseDownInfo", void 0);
73
+
74
+ _defineProperty(_assertThisInitialized(_this), "mouseDelayTimer", void 0);
75
+
76
+ _defineProperty(_assertThisInitialized(_this), "isMouseDelayMet", void 0);
77
+
78
+ _defineProperty(_assertThisInitialized(_this), "mouseDown", function (e) {
79
+ // Left mouse button?
80
+ if (e.button !== 0) {
81
+ return;
82
+ }
83
+
84
+ var result = _this.handleMouseDown(getPositionInfoFromMouseEvent(e));
85
+
86
+ if (result && e.cancelable) {
87
+ e.preventDefault();
88
+ }
89
+ });
90
+
91
+ _defineProperty(_assertThisInitialized(_this), "mouseMove", function (e) {
92
+ _this.handleMouseMove(e, getPositionInfoFromMouseEvent(e));
93
+ });
94
+
95
+ _defineProperty(_assertThisInitialized(_this), "mouseUp", function (e) {
96
+ _this.handleMouseUp(getPositionInfoFromMouseEvent(e));
97
+ });
98
+
99
+ _defineProperty(_assertThisInitialized(_this), "touchStart", function (e) {
100
+ if (!e) {
101
+ return;
102
+ }
103
+
104
+ if (e.touches.length > 1) {
105
+ return;
106
+ }
107
+
108
+ var touch = e.changedTouches[0];
109
+
110
+ _this.handleMouseDown(getPositionInfoFromTouch(touch, e));
111
+ });
112
+
113
+ _defineProperty(_assertThisInitialized(_this), "touchMove", function (e) {
114
+ if (!e) {
115
+ return;
116
+ }
117
+
118
+ if (e.touches.length > 1) {
119
+ return;
120
+ }
121
+
122
+ var touch = e.changedTouches[0];
123
+
124
+ _this.handleMouseMove(e, getPositionInfoFromTouch(touch, e));
125
+ });
126
+
127
+ _defineProperty(_assertThisInitialized(_this), "touchEnd", function (e) {
128
+ if (!e) {
129
+ return;
130
+ }
131
+
132
+ if (e.touches.length > 1) {
133
+ return;
134
+ }
135
+
136
+ var touch = e.changedTouches[0];
137
+
138
+ _this.handleMouseUp(getPositionInfoFromTouch(touch, e));
139
+ });
140
+
141
+ return _this;
142
+ }
143
+
144
+ _createClass(MouseWidget, [{
145
+ key: "init",
146
+ value: function init() {
147
+ var element = this.$el.get(0);
148
+
149
+ if (element) {
89
150
  element.addEventListener("mousedown", this.mouseDown, {
90
- passive: false
151
+ passive: false
91
152
  });
92
153
  element.addEventListener("touchstart", this.touchStart, {
93
- passive: false
154
+ passive: false
94
155
  });
95
- this.isMouseStarted = false;
96
- this.mouseDelay = 0;
97
- this.mouseDelayTimer = null;
98
- this.isMouseDelayMet = false;
99
- this.mouseDownInfo = null;
100
- };
101
- MouseWidget.prototype.deinit = function () {
102
- var el = this.$el.get(0);
103
- el.removeEventListener("mousedown", this.mouseDown);
104
- el.removeEventListener("touchstart", this.touchStart);
105
- document.removeEventListener("mousemove", this.mouseMove);
106
- document.removeEventListener("touchmove", this.touchMove);
107
- document.removeEventListener("mouseup", this.mouseUp);
108
- document.removeEventListener("touchend", this.touchEnd);
109
- };
110
- MouseWidget.prototype.handleMouseDown = function (positionInfo) {
111
- // We may have missed mouseup (out of window)
112
- if (this.isMouseStarted) {
113
- this.handleMouseUp(positionInfo);
114
- }
115
- this.mouseDownInfo = positionInfo;
116
- if (!this.mouseCapture(positionInfo)) {
117
- return false;
118
- }
119
- this.handleStartMouse();
120
- return true;
121
- };
122
- MouseWidget.prototype.handleStartMouse = function () {
123
- document.addEventListener("mousemove", this.mouseMove, {
124
- passive: false
125
- });
126
- document.addEventListener("touchmove", this.touchMove, {
127
- passive: false
128
- });
129
- document.addEventListener("mouseup", this.mouseUp, { passive: false });
130
- document.addEventListener("touchend", this.touchEnd, {
131
- passive: false
156
+ }
157
+
158
+ this.isMouseStarted = false;
159
+ this.mouseDelayTimer = null;
160
+ this.isMouseDelayMet = false;
161
+ this.mouseDownInfo = null;
162
+ }
163
+ }, {
164
+ key: "deinit",
165
+ value: function deinit() {
166
+ var el = this.$el.get(0);
167
+
168
+ if (el) {
169
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-member-access
170
+ el.removeEventListener("mousedown", this.mouseDown, {
171
+ passive: false
172
+ }); // eslint-disable-next-line @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-member-access
173
+
174
+ el.removeEventListener("touchstart", this.touchStart, {
175
+ passive: false
132
176
  });
133
- if (this.mouseDelay) {
134
- this.startMouseDelayTimer();
135
- }
136
- };
137
- MouseWidget.prototype.startMouseDelayTimer = function () {
138
- var _this = this;
139
- if (this.mouseDelayTimer) {
140
- clearTimeout(this.mouseDelayTimer);
141
- }
142
- this.mouseDelayTimer = window.setTimeout(function () {
143
- _this.isMouseDelayMet = true;
144
- }, this.mouseDelay);
145
- this.isMouseDelayMet = false;
146
- };
147
- MouseWidget.prototype.handleMouseMove = function (e, positionInfo) {
148
- if (this.isMouseStarted) {
149
- this.mouseDrag(positionInfo);
150
- if (e.cancelable) {
151
- e.preventDefault();
152
- }
153
- return;
154
- }
155
- if (this.mouseDelay && !this.isMouseDelayMet) {
156
- return;
157
- }
158
- if (this.mouseDownInfo) {
159
- this.isMouseStarted = this.mouseStart(this.mouseDownInfo) !== false;
160
- }
161
- if (this.isMouseStarted) {
162
- this.mouseDrag(positionInfo);
163
- if (e.cancelable) {
164
- e.preventDefault();
165
- }
177
+ }
178
+
179
+ this.removeMouseMoveEventListeners();
180
+ }
181
+ }, {
182
+ key: "handleMouseDown",
183
+ value: function handleMouseDown(positionInfo) {
184
+ // We may have missed mouseup (out of window)
185
+ if (this.isMouseStarted) {
186
+ this.handleMouseUp(positionInfo);
187
+ }
188
+
189
+ this.mouseDownInfo = positionInfo;
190
+
191
+ if (!this.mouseCapture(positionInfo)) {
192
+ return false;
193
+ }
194
+
195
+ this.handleStartMouse();
196
+ return true;
197
+ }
198
+ }, {
199
+ key: "handleStartMouse",
200
+ value: function handleStartMouse() {
201
+ document.addEventListener("mousemove", this.mouseMove, {
202
+ passive: false
203
+ });
204
+ document.addEventListener("touchmove", this.touchMove, {
205
+ passive: false
206
+ });
207
+ document.addEventListener("mouseup", this.mouseUp, {
208
+ passive: false
209
+ });
210
+ document.addEventListener("touchend", this.touchEnd, {
211
+ passive: false
212
+ });
213
+ var mouseDelay = this.getMouseDelay();
214
+
215
+ if (mouseDelay) {
216
+ this.startMouseDelayTimer(mouseDelay);
217
+ } else {
218
+ this.isMouseDelayMet = true;
219
+ }
220
+ }
221
+ }, {
222
+ key: "startMouseDelayTimer",
223
+ value: function startMouseDelayTimer(mouseDelay) {
224
+ var _this2 = this;
225
+
226
+ if (this.mouseDelayTimer) {
227
+ clearTimeout(this.mouseDelayTimer);
228
+ }
229
+
230
+ this.mouseDelayTimer = window.setTimeout(function () {
231
+ if (_this2.mouseDownInfo) {
232
+ _this2.isMouseDelayMet = true;
166
233
  }
167
- else {
168
- this.handleMouseUp(positionInfo);
234
+ }, mouseDelay);
235
+ this.isMouseDelayMet = false;
236
+ }
237
+ }, {
238
+ key: "handleMouseMove",
239
+ value: function handleMouseMove(e, positionInfo) {
240
+ if (this.isMouseStarted) {
241
+ this.mouseDrag(positionInfo);
242
+
243
+ if (e.cancelable) {
244
+ e.preventDefault();
169
245
  }
170
- };
171
- MouseWidget.prototype.handleMouseUp = function (positionInfo) {
172
- document.removeEventListener("mousemove", this.mouseMove);
173
- document.removeEventListener("touchmove", this.touchMove);
174
- document.removeEventListener("mouseup", this.mouseUp);
175
- document.removeEventListener("touchend", this.touchEnd);
176
- if (this.isMouseStarted) {
177
- this.isMouseStarted = false;
178
- this.mouseStop(positionInfo);
246
+
247
+ return;
248
+ }
249
+
250
+ if (!this.isMouseDelayMet) {
251
+ return;
252
+ }
253
+
254
+ if (this.mouseDownInfo) {
255
+ this.isMouseStarted = this.mouseStart(this.mouseDownInfo) !== false;
256
+ }
257
+
258
+ if (this.isMouseStarted) {
259
+ this.mouseDrag(positionInfo);
260
+
261
+ if (e.cancelable) {
262
+ e.preventDefault();
179
263
  }
180
- };
181
- return MouseWidget;
182
- }(simple_widget_1["default"]));
183
- exports["default"] = MouseWidget;
264
+ } else {
265
+ this.handleMouseUp(positionInfo);
266
+ }
267
+ }
268
+ }, {
269
+ key: "handleMouseUp",
270
+ value: function handleMouseUp(positionInfo) {
271
+ this.removeMouseMoveEventListeners();
272
+ this.isMouseDelayMet = false;
273
+ this.mouseDownInfo = null;
274
+
275
+ if (this.isMouseStarted) {
276
+ this.isMouseStarted = false;
277
+ this.mouseStop(positionInfo);
278
+ }
279
+ }
280
+ }, {
281
+ key: "removeMouseMoveEventListeners",
282
+ value: function removeMouseMoveEventListeners() {
283
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-member-access
284
+ document.removeEventListener("mousemove", this.mouseMove, {
285
+ passive: false
286
+ }); // eslint-disable-next-line @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-member-access
287
+
288
+ document.removeEventListener("touchmove", this.touchMove, {
289
+ passive: false
290
+ }); // eslint-disable-next-line @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-member-access
291
+
292
+ document.removeEventListener("mouseup", this.mouseUp, {
293
+ passive: false
294
+ }); // eslint-disable-next-line @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-member-access
295
+
296
+ document.removeEventListener("touchend", this.touchEnd, {
297
+ passive: false
298
+ });
299
+ }
300
+ }]);
301
+
302
+ return MouseWidget;
303
+ }(_simple["default"]);
304
+
305
+ var _default = MouseWidget;
306
+ exports["default"] = _default;