targetj 1.0.253 → 1.0.255

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/build/$Dom.js CHANGED
@@ -133,10 +133,15 @@ var $Dom = /*#__PURE__*/function () {
133
133
  }
134
134
  return slot;
135
135
  }
136
+ }, {
137
+ key: "isManagedChildNode",
138
+ value: function isManagedChildNode(node) {
139
+ return (node === null || node === void 0 ? void 0 : node.nodeType) === 1 && node.getAttribute("tgjs") === "true";
140
+ }
136
141
  }, {
137
142
  key: "enableSlotMode",
138
143
  value: function enableSlotMode() {
139
- var _this$element4;
144
+ var _this = this;
140
145
  if (this.slotModeEnabled) {
141
146
  return;
142
147
  }
@@ -144,32 +149,24 @@ var $Dom = /*#__PURE__*/function () {
144
149
  this.slotModeEnabled = true;
145
150
  return;
146
151
  }
147
- var existingSlot = this.findContentSlot();
148
- if (existingSlot) {
149
- if (this.element.firstChild !== existingSlot) {
150
- this.element.insertBefore(existingSlot, this.element.firstChild);
152
+ var slot = this.findContentSlot();
153
+ if (!slot) {
154
+ var existingNodes = Array.from(this.element.childNodes);
155
+ slot = document.createElement("div");
156
+ slot.setAttribute("data-tj-slot", "content");
157
+ this.element.insertBefore(slot, this.element.firstChild);
158
+ for (var _i = 0, _existingNodes = existingNodes; _i < _existingNodes.length; _i++) {
159
+ var node = _existingNodes[_i];
160
+ if (!this.isManagedChildNode(node)) {
161
+ slot.appendChild(node);
162
+ }
151
163
  }
152
- this.contentSlot = existingSlot;
153
- this.slotModeEnabled = true;
154
- this.hasRealChildren = Array.from(this.element.childNodes).some(function (node) {
155
- return node !== existingSlot;
156
- });
157
- return;
158
- }
159
- if (!((_this$element4 = this.element) !== null && _this$element4 !== void 0 && _this$element4.firstChild)) {
160
- this.slotModeEnabled = true;
161
- return;
162
- }
163
- var existingNodes = Array.from(this.element.childNodes);
164
- var slot = document.createElement("div");
165
- slot.setAttribute("data-tj-slot", "content");
166
- this.element.insertBefore(slot, this.element.firstChild);
167
- for (var _i = 0, _existingNodes = existingNodes; _i < _existingNodes.length; _i++) {
168
- var node = _existingNodes[_i];
169
- slot.appendChild(node);
170
164
  }
171
165
  this.contentSlot = slot;
172
166
  this.slotModeEnabled = true;
167
+ this.hasRealChildren = Array.from(this.element.children).some(function (child) {
168
+ return child !== slot && _this.isManagedChildNode(child);
169
+ });
173
170
  }
174
171
  }, {
175
172
  key: "ensureSlotMode",
@@ -201,8 +198,8 @@ var $Dom = /*#__PURE__*/function () {
201
198
  }, {
202
199
  key: "getTagName",
203
200
  value: function getTagName() {
204
- var _this$element5;
205
- return (_this$element5 = this.element) === null || _this$element5 === void 0 || (_this$element5 = _this$element5.tagName) === null || _this$element5 === void 0 ? void 0 : _this$element5.toLowerCase();
201
+ var _this$element4;
202
+ return (_this$element4 = this.element) === null || _this$element4 === void 0 || (_this$element4 = _this$element4.tagName) === null || _this$element4 === void 0 ? void 0 : _this$element4.toLowerCase();
206
203
  }
207
204
  }, {
208
205
  key: "setSelector",
@@ -291,9 +288,9 @@ var $Dom = /*#__PURE__*/function () {
291
288
  }, {
292
289
  key: "setStyleByMap",
293
290
  value: function setStyleByMap(attrMap) {
294
- var _this = this;
291
+ var _this2 = this;
295
292
  Object.keys(attrMap).forEach(function (key) {
296
- _this.style(key, attrMap[key]);
293
+ _this2.style(key, attrMap[key]);
297
294
  });
298
295
  }
299
296
  }, {
@@ -578,14 +575,14 @@ var $Dom = /*#__PURE__*/function () {
578
575
  }, {
579
576
  key: "getScrollTop",
580
577
  value: function getScrollTop() {
581
- var _this$element$scrollT, _this$element6;
582
- return (_this$element$scrollT = (_this$element6 = this.element) === null || _this$element6 === void 0 ? void 0 : _this$element6.scrollTop) !== null && _this$element$scrollT !== void 0 ? _this$element$scrollT : 0;
578
+ var _this$element$scrollT, _this$element5;
579
+ return (_this$element$scrollT = (_this$element5 = this.element) === null || _this$element5 === void 0 ? void 0 : _this$element5.scrollTop) !== null && _this$element$scrollT !== void 0 ? _this$element$scrollT : 0;
583
580
  }
584
581
  }, {
585
582
  key: "getScrollLeft",
586
583
  value: function getScrollLeft() {
587
- var _this$element$scrollL, _this$element7;
588
- return (_this$element$scrollL = (_this$element7 = this.element) === null || _this$element7 === void 0 ? void 0 : _this$element7.scrollLeft) !== null && _this$element$scrollL !== void 0 ? _this$element$scrollL : 0;
584
+ var _this$element$scrollL, _this$element6;
585
+ return (_this$element$scrollL = (_this$element6 = this.element) === null || _this$element6 === void 0 ? void 0 : _this$element6.scrollLeft) !== null && _this$element$scrollL !== void 0 ? _this$element$scrollL : 0;
589
586
  }
590
587
  }], [{
591
588
  key: "createTemplate",
@@ -94,6 +94,7 @@ var EventListener = /*#__PURE__*/function () {
94
94
  this.bindedHandleWindowEvent = this.handleWindowEvent.bind(this);
95
95
  this.bindedHandleEvent = this.handleEvent.bind(this);
96
96
  this.bindedParentHandleEvent = this.handleDocEvent.bind(this);
97
+ this.maxPointerMoveDistance = 0;
97
98
  }
98
99
  return _createClass(EventListener, [{
99
100
  key: "detachWindowEvents",
@@ -223,38 +224,43 @@ var EventListener = /*#__PURE__*/function () {
223
224
  }, {
224
225
  key: "resetEventsOnTimeout",
225
226
  value: function resetEventsOnTimeout() {
226
- if (this.scrollEndTimeStamp.x > 0 || this.scrollEndTimeStamp.y > 0 || this.currentTouch.pinchDelta) {
227
- var now = TUtil.now();
228
- var diff = Math.max(this.scrollEndTimeStamp.x - now, this.scrollEndTimeStamp.y - now);
229
- if (diff > 100) {
230
- this.currentTouch.deltaY *= 0.95;
231
- this.currentTouch.deltaX *= 0.95;
232
- this.currentTouch.pinchDelta *= 0.95;
233
- if (Math.abs(this.currentTouch.deltaY) < 0.1) {
234
- this.currentTouch.deltaY = 0;
235
- }
236
- if (Math.abs(this.currentTouch.deltaX) < 0.1) {
237
- this.currentTouch.deltaX = 0;
238
- }
239
- if (Math.abs(this.currentTouch.pinchDelta) < 0.1) {
240
- this.currentTouch.pinchDelta = 0;
241
- }
242
- }
243
- if (diff <= 0) {
227
+ var hasPendingScroll = this.scrollEndTimeStamp.x > 0 || this.scrollEndTimeStamp.y > 0 || this.currentTouch.pinchDelta !== 0;
228
+ if (!hasPendingScroll) {
229
+ return;
230
+ }
231
+ if (this.touchCount > 0) {
232
+ return;
233
+ }
234
+ var now = TUtil.now();
235
+ var diff = Math.max(this.scrollEndTimeStamp.x - now, this.scrollEndTimeStamp.y - now);
236
+ if (diff > 100) {
237
+ this.currentTouch.deltaY *= 0.95;
238
+ this.currentTouch.deltaX *= 0.95;
239
+ this.currentTouch.pinchDelta *= 0.95;
240
+ if (Math.abs(this.currentTouch.deltaY) < 0.1) {
244
241
  this.currentTouch.deltaY = 0;
245
- this.currentTouch.deltaX = 0;
246
- this.currentTouch.pinchDelta = 0;
247
242
  }
248
- if (!this.currentTouch.deltaX && this.scrollEndTimeStamp.x && now >= this.scrollEndTimeStamp.x && this.touchCount === 0) {
249
- this.scrollEndTimeStamp.x = 0;
250
- this.queueScrollEndEvent('x', this.currentHandlers.scrollLeft);
243
+ if (Math.abs(this.currentTouch.deltaX) < 0.1) {
244
+ this.currentTouch.deltaX = 0;
251
245
  }
252
- if (!this.currentTouch.deltaY && this.scrollEndTimeStamp.y && now >= this.scrollEndTimeStamp.y && this.touchCount === 0) {
253
- this.queueScrollEndEvent('y', this.currentHandlers.scrollTop);
254
- this.scrollEndTimeStamp.y = 0;
246
+ if (Math.abs(this.currentTouch.pinchDelta) < 0.1) {
247
+ this.currentTouch.pinchDelta = 0;
255
248
  }
256
- getRunScheduler().schedule(10, 'scroll decay');
257
249
  }
250
+ if (diff <= 0) {
251
+ this.currentTouch.deltaY = 0;
252
+ this.currentTouch.deltaX = 0;
253
+ this.currentTouch.pinchDelta = 0;
254
+ }
255
+ if (!this.currentTouch.deltaX && this.scrollEndTimeStamp.x && now >= this.scrollEndTimeStamp.x) {
256
+ this.scrollEndTimeStamp.x = 0;
257
+ this.queueScrollEndEvent('x', this.currentHandlers.scrollLeft);
258
+ }
259
+ if (!this.currentTouch.deltaY && this.scrollEndTimeStamp.y && now >= this.scrollEndTimeStamp.y) {
260
+ this.queueScrollEndEvent('y', this.currentHandlers.scrollTop);
261
+ this.scrollEndTimeStamp.y = 0;
262
+ }
263
+ getRunScheduler().schedule(10, 'scroll decay');
258
264
  }
259
265
  }, {
260
266
  key: "findEventHandlers",
@@ -448,6 +454,7 @@ var EventListener = /*#__PURE__*/function () {
448
454
  switch (eventName) {
449
455
  case 'mousedown':
450
456
  case 'touchstart':
457
+ this.maxPointerMoveDistance = 0;
451
458
  this.clearStart();
452
459
  this.clearEnd();
453
460
  this.clearTouch();
@@ -509,7 +516,7 @@ var EventListener = /*#__PURE__*/function () {
509
516
  }
510
517
  this.end0 = this.getTouch(event);
511
518
  var clickHandler = SearchUtil.findFirstClickHandler(tmodel);
512
- var canAcceptClick = !this.start0 || clickHandler === this.currentHandlers.click && (clickHandler !== this.currentHandlers.swipe || this.getSwipeDistance() < 5);
519
+ var canAcceptClick = !this.start0 || clickHandler === this.currentHandlers.click && this.maxPointerMoveDistance < EventListener.CLICK_MOVE_THRESHOLD;
513
520
  if (clickHandler && canAcceptClick) {
514
521
  this.eventQueue.length = 0;
515
522
  this.eventQueue.push({
@@ -524,6 +531,7 @@ var EventListener = /*#__PURE__*/function () {
524
531
  }
525
532
  this.clearEnd();
526
533
  this.clearStart();
534
+ this.maxPointerMoveDistance = 0;
527
535
  this.touchCount = 0;
528
536
  event.stopPropagation();
529
537
  break;
@@ -555,6 +563,7 @@ var EventListener = /*#__PURE__*/function () {
555
563
  this.clearStart();
556
564
  this.clearEnd();
557
565
  this.clearTouch();
566
+ this.maxPointerMoveDistance = 0;
558
567
  this.touchCount = 0;
559
568
  event.stopPropagation();
560
569
  break;
@@ -726,6 +735,7 @@ var EventListener = /*#__PURE__*/function () {
726
735
  this.windowScrollEndTimer = 0;
727
736
  this.scrollEndTimeStamp.x = 0;
728
737
  this.scrollEndTimeStamp.y = 0;
738
+ this.maxPointerMoveDistance = 0;
729
739
  this.currentHandlers = {
730
740
  touch: null,
731
741
  click: null,
@@ -773,14 +783,6 @@ var EventListener = /*#__PURE__*/function () {
773
783
  value: function swipeY() {
774
784
  return this.cursor.y - this.swipeStartY;
775
785
  }
776
- }, {
777
- key: "getSwipeDistance",
778
- value: function getSwipeDistance() {
779
- if (this.start0 && this.end0) {
780
- return TUtil.distance(this.start0.originalX, this.start0.originalY, this.end0.x, this.end0.y);
781
- }
782
- return 0;
783
- }
784
786
  }, {
785
787
  key: "pinchDelta",
786
788
  value: function pinchDelta() {
@@ -1040,6 +1042,8 @@ var EventListener = /*#__PURE__*/function () {
1040
1042
  this.start0.x = this.end0 ? this.end0.x : this.start0.x;
1041
1043
  this.end0 = this.getTouch(event);
1042
1044
  if (TUtil.isDefined(this.end0)) {
1045
+ var distance = TUtil.distance(this.start0.originalX, this.start0.originalY, this.end0.x, this.end0.y);
1046
+ this.maxPointerMoveDistance = Math.max(this.maxPointerMoveDistance, distance);
1043
1047
  var deltaX = this.start0.x - this.end0.x;
1044
1048
  var deltaY = this.start0.y - this.end0.y;
1045
1049
  this.setDeltaXDeltaY(deltaX, deltaY, 'touch');
@@ -1144,4 +1148,5 @@ var EventListener = /*#__PURE__*/function () {
1144
1148
  }();
1145
1149
  _defineProperty(EventListener, "MAX_EVENT_QUEUE_SIZE", 10);
1146
1150
  _defineProperty(EventListener, "MAX_EVENT_TYPE_CAPACITY", 2);
1151
+ _defineProperty(EventListener, "CLICK_MOVE_THRESHOLD", 10);
1147
1152
  export { EventListener };