@syncfusion/ej2-base 26.1.35-806029 → 26.1.35-813929

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 (2) hide show
  1. package/package.json +1 -1
  2. package/src/draggable.js +73 -36
package/package.json CHANGED
@@ -221,6 +221,6 @@
221
221
  "url": "git+https://github.com/syncfusion/ej2-javascript-ui-controls.git"
222
222
  },
223
223
  "typings": "index.d.ts",
224
- "version": "26.1.35-806029",
224
+ "version": "26.1.35-813929",
225
225
  "sideEffects": true
226
226
  }
package/src/draggable.js CHANGED
@@ -1,22 +1,22 @@
1
- var __extends = (this && this.__extends) || (function () {
2
- var extendStatics = function (d, b) {
3
- extendStatics = Object.setPrototypeOf ||
4
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
5
- function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
6
- return extendStatics(d, b);
7
- };
8
- return function (d, b) {
9
- extendStatics(d, b);
10
- function __() { this.constructor = d; }
11
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
12
- };
13
- })();
14
- var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
15
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
16
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
17
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
18
- return c > 3 && r && Object.defineProperty(target, key, r), r;
19
- };
1
+ var __extends = (this && this.__extends) || (function () {
2
+ var extendStatics = function (d, b) {
3
+ extendStatics = Object.setPrototypeOf ||
4
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
5
+ function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
6
+ return extendStatics(d, b);
7
+ };
8
+ return function (d, b) {
9
+ extendStatics(d, b);
10
+ function __() { this.constructor = d; }
11
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
12
+ };
13
+ })();
14
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
15
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
16
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
17
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
18
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
19
+ };
20
20
  /* eslint-disable @typescript-eslint/no-explicit-any */
21
21
  import { Base } from './base';
22
22
  import { Browser } from './browser';
@@ -79,6 +79,7 @@ var Draggable = /** @class */ (function (_super) {
79
79
  _this.parentScrollX = 0;
80
80
  _this.parentScrollY = 0;
81
81
  _this.droppables = {};
82
+ _this.isTouchInteraction = false;
82
83
  _this.bind();
83
84
  return _this;
84
85
  }
@@ -93,6 +94,41 @@ var Draggable = /** @class */ (function (_super) {
93
94
  Draggable.getDefaultPosition = function () {
94
95
  return extend({}, defaultPosition);
95
96
  };
97
+
98
+ Draggable.prototype.getDragEventName = function (type) {
99
+ var eventName;
100
+
101
+ switch (type) {
102
+ case 'move':
103
+ eventName = Browser.touchMoveEvent;
104
+ break;
105
+ case 'end':
106
+ eventName = Browser.touchEndEvent;
107
+ break;
108
+ case 'cancel':
109
+ eventName = Browser.touchCancelEvent;
110
+ break;
111
+ default:
112
+ eventName = Browser.touchStartEvent;
113
+ break;
114
+ }
115
+
116
+ if (Browser.isSafari()) {
117
+ var suffix = {
118
+ start: 'pointerdown mousedown',
119
+ move: 'pointermove mousemove',
120
+ end: 'pointerup mouseup',
121
+ cancel: 'pointercancel mouseleave'
122
+ };
123
+
124
+ if (!this.isTouchInteraction) {
125
+ eventName += ' ' + suffix[type];
126
+ }
127
+ }
128
+
129
+ return eventName;
130
+ };
131
+
96
132
  Draggable.prototype.toggleEvents = function (isUnWire) {
97
133
  var ele;
98
134
  if (!isUndefined(this.handle)) {
@@ -100,10 +136,10 @@ var Draggable = /** @class */ (function (_super) {
100
136
  }
101
137
  var handler = (this.enableTapHold && Browser.isDevice && Browser.isTouch) ? this.mobileInitialize : this.initialize;
102
138
  if (isUnWire) {
103
- EventHandler.remove(ele || this.element, Browser.isSafari() ? 'touchstart' : Browser.touchStartEvent, handler);
139
+ EventHandler.remove(ele || this.element, this.getDragEventName('start'), handler);
104
140
  }
105
141
  else {
106
- EventHandler.add(ele || this.element, Browser.isSafari() ? 'touchstart' : Browser.touchStartEvent, handler, this);
142
+ EventHandler.add(ele || this.element, this.getDragEventName('start'), handler, this);
107
143
  }
108
144
  };
109
145
  /* istanbul ignore next */
@@ -115,14 +151,14 @@ var Draggable = /** @class */ (function (_super) {
115
151
  _this.removeTapholdTimer();
116
152
  _this.initialize(evt, target);
117
153
  }, this.tapHoldThreshold);
118
- EventHandler.add(document, Browser.isSafari() ? 'touchmove' : Browser.touchMoveEvent, this.removeTapholdTimer, this);
119
- EventHandler.add(document, Browser.isSafari() ? 'touchend' : Browser.touchEndEvent, this.removeTapholdTimer, this);
154
+ EventHandler.add(document, this.getDragEventName('move'), this.removeTapholdTimer, this);
155
+ EventHandler.add(document, this.getDragEventName('end'), this.removeTapholdTimer, this);
120
156
  };
121
157
  /* istanbul ignore next */
122
158
  Draggable.prototype.removeTapholdTimer = function () {
123
159
  clearTimeout(this.tapHoldTimer);
124
- EventHandler.remove(document, Browser.isSafari() ? 'touchmove' : Browser.touchMoveEvent, this.removeTapholdTimer);
125
- EventHandler.remove(document, Browser.isSafari() ? 'touchend' : Browser.touchEndEvent, this.removeTapholdTimer);
160
+ EventHandler.remove(document, this.getDragEventName('move'), this.removeTapholdTimer);
161
+ EventHandler.remove(document, this.getDragEventName('end'), this.removeTapholdTimer);
126
162
  };
127
163
  /* istanbul ignore next */
128
164
  Draggable.prototype.getScrollableParent = function (element, axis) {
@@ -166,6 +202,7 @@ var Draggable = /** @class */ (function (_super) {
166
202
  var horizontalScrollParent = this.getScrollableParent(this.element.parentNode, 'horizontal');
167
203
  };
168
204
  Draggable.prototype.initialize = function (evt, curTarget) {
205
+ this.isTouchInteraction = evt.pointerType === 'touch' || (evt.changedTouches && evt.changedTouches.length);
169
206
  this.currentStateTarget = evt.target;
170
207
  if (this.isDragStarted()) {
171
208
  return;
@@ -213,8 +250,8 @@ var Draggable = /** @class */ (function (_super) {
213
250
  this.intDragStart(evt);
214
251
  }
215
252
  else {
216
- EventHandler.add(document, Browser.isSafari() ? 'touchmove' : Browser.touchMoveEvent, this.intDragStart, this);
217
- EventHandler.add(document, Browser.isSafari() ? 'touchend' : Browser.touchEndEvent, this.intDestroy, this);
253
+ EventHandler.add(document, this.getDragEventName('move'), this.intDragStart, this);
254
+ EventHandler.add(document, this.getDragEventName('end'), this.intDestroy, this);
218
255
  }
219
256
  this.toggleEvents(true);
220
257
  if (evt.type !== 'touchstart' && this.isPreventSelect) {
@@ -313,8 +350,8 @@ var Draggable = /** @class */ (function (_super) {
313
350
  }
314
351
  this.dragElePosition = { top: pos.top, left: pos.left };
315
352
  setStyleAttribute(dragTargetElement, this.getDragPosition({ position: 'absolute', left: posValue.left, top: posValue.top }));
316
- EventHandler.remove(document, Browser.isSafari() ? 'touchmove' : Browser.touchMoveEvent, this.intDragStart);
317
- EventHandler.remove(document, Browser.isSafari() ? 'touchend' : Browser.touchEndEvent, this.intDestroy);
353
+ EventHandler.remove(document, this.getDragEventName('move'), this.intDragStart);
354
+ EventHandler.remove(document, this.getDragEventName('end'), this.intDestroy);
318
355
  if (!isBlazor()) {
319
356
  this.bindDragEvents(dragTargetElement);
320
357
  }
@@ -322,8 +359,8 @@ var Draggable = /** @class */ (function (_super) {
322
359
  };
323
360
  Draggable.prototype.bindDragEvents = function (dragTargetElement) {
324
361
  if (isVisible(dragTargetElement)) {
325
- EventHandler.add(document, Browser.isSafari() ? 'touchmove' : Browser.touchMoveEvent, this.intDrag, this);
326
- EventHandler.add(document, Browser.isSafari() ? 'touchend' : Browser.touchEndEvent, this.intDragStop, this);
362
+ EventHandler.add(document, this.getDragEventName('move'), this.intDrag, this);
363
+ EventHandler.add(document, this.getDragEventName('end'), this.intDragStop, this);
327
364
  this.setGlobalDroppables(false, this.element, dragTargetElement);
328
365
  }
329
366
  else {
@@ -666,10 +703,10 @@ var Draggable = /** @class */ (function (_super) {
666
703
  this.toggleEvents();
667
704
  document.body.classList.remove('e-prevent-select');
668
705
  this.element.setAttribute('aria-grabbed', 'false');
669
- EventHandler.remove(document, Browser.isSafari() ? 'touchmove' : Browser.touchMoveEvent, this.intDragStart);
670
- EventHandler.remove(document, Browser.isSafari() ? 'touchend' : Browser.touchEndEvent, this.intDragStop);
671
- EventHandler.remove(document, Browser.isSafari() ? 'touchend' : Browser.touchEndEvent, this.intDestroy);
672
- EventHandler.remove(document, Browser.isSafari() ? 'touchmove' : Browser.touchMoveEvent, this.intDrag);
706
+ EventHandler.remove(document, this.getDragEventName('move'), this.intDragStart);
707
+ EventHandler.remove(document, this.getDragEventName('end'), this.intDragStop);
708
+ EventHandler.remove(document, this.getDragEventName('end'), this.intDestroy);
709
+ EventHandler.remove(document, this.getDragEventName('move'), this.intDrag);
673
710
  if (this.isDragStarted()) {
674
711
  this.isDragStarted(true);
675
712
  }
@@ -919,4 +956,4 @@ var Draggable = /** @class */ (function (_super) {
919
956
  ], Draggable);
920
957
  return Draggable;
921
958
  }(Base));
922
- export { Draggable };
959
+ export { Draggable };