igniteui-angular 22.1.5 → 22.1.6

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.
@@ -1108,9 +1108,10 @@ class IgxTouchManager {
1108
1108
  return;
1109
1109
  }
1110
1110
  const gesture = this._createEvent(event);
1111
- // Defer `panStart` until movement actually begins, mirroring Hammer's `panstart`.
1112
- // A press with no movement (a tap) therefore never raises `panStart`.
1113
1111
  if (!this._panStarted) {
1112
+ if (!this._canStartPan(gesture)) {
1113
+ return;
1114
+ }
1114
1115
  this._panStarted = true;
1115
1116
  if (this.callbacks.panStart) {
1116
1117
  this._runInAngular(() => this.callbacks.panStart?.(gesture));
@@ -1128,15 +1129,15 @@ class IgxTouchManager {
1128
1129
  if (!this._tracking || event.pointerId !== this._pointerId || !this._accepts(event.pointerType)) {
1129
1130
  return;
1130
1131
  }
1131
- this._tracking = false;
1132
- this._pointerId = null;
1133
1132
  const gesture = this._createEvent(event);
1133
+ const panStarted = this._panStarted;
1134
+ this._resetTracking();
1134
1135
  this._runInAngular(() => {
1135
1136
  if (this.callbacks.tap && gesture.distance < this._tapThreshold) {
1136
1137
  this.callbacks.tap(gesture);
1137
1138
  return;
1138
1139
  }
1139
- if (this.callbacks.swipe &&
1140
+ if (panStarted && this.callbacks.swipe &&
1140
1141
  gesture.velocity > this._swipeVelocityThreshold &&
1141
1142
  Math.abs(gesture.deltaX) > Math.abs(gesture.deltaY)) {
1142
1143
  this.callbacks.swipe(gesture);
@@ -1151,10 +1152,9 @@ class IgxTouchManager {
1151
1152
  if (!this._tracking || event.pointerId !== this._pointerId) {
1152
1153
  return;
1153
1154
  }
1154
- this._tracking = false;
1155
- this._pointerId = null;
1155
+ const gesture = this._createEvent(event);
1156
+ this._resetTracking();
1156
1157
  if (this.callbacks.panCancel) {
1157
- const gesture = this._createEvent(event);
1158
1158
  this._runInAngular(() => this.callbacks.panCancel?.(gesture));
1159
1159
  }
1160
1160
  };
@@ -1162,14 +1162,17 @@ class IgxTouchManager {
1162
1162
  if (!(event instanceof TouchEvent)) {
1163
1163
  return;
1164
1164
  }
1165
- // Prevent scrolling only while a gesture is actively tracked.
1166
- if (this._tracking && event.cancelable) {
1165
+ // Preserve native scrolling and compatibility clicks while the contact is
1166
+ // only a tap candidate. Suppress scrolling after a pan is recognized.
1167
+ if (this._tracking && this._panStarted && event.cancelable) {
1167
1168
  event.preventDefault();
1168
1169
  }
1169
1170
  };
1170
1171
  this._pointerTypes = options.pointerTypes ?? ['touch', 'pen'];
1171
1172
  this._setPointerCapture = options.setPointerCapture ?? true;
1172
1173
  this._tapThreshold = options.tapThreshold ?? 0;
1174
+ this._panThreshold = options.panThreshold ?? 0;
1175
+ this._panAxis = options.panAxis ?? 'all';
1173
1176
  this._swipeVelocityThreshold = options.swipeVelocityThreshold ?? 0.3;
1174
1177
  this._canStart = options.canStart ?? null;
1175
1178
  this._ngZone = options.ngZone ?? null;
@@ -1196,15 +1199,14 @@ class IgxTouchManager {
1196
1199
  }
1197
1200
  /** Detaches all listeners and stops tracking. */
1198
1201
  destroy() {
1199
- if (!this._supported) {
1200
- return;
1202
+ if (this._supported) {
1203
+ this.target.removeEventListener('pointerdown', this._onPointerDown);
1204
+ this.target.removeEventListener('pointermove', this._onPointerMove);
1205
+ this.target.removeEventListener('pointerup', this._onPointerUp);
1206
+ this.target.removeEventListener('pointercancel', this._onPointerCancel);
1207
+ this.target.removeEventListener('touchmove', this._onTouchMove);
1201
1208
  }
1202
- this.target.removeEventListener('pointerdown', this._onPointerDown);
1203
- this.target.removeEventListener('pointermove', this._onPointerMove);
1204
- this.target.removeEventListener('pointerup', this._onPointerUp);
1205
- this.target.removeEventListener('pointercancel', this._onPointerCancel);
1206
- this.target.removeEventListener('touchmove', this._onTouchMove);
1207
- this._tracking = false;
1209
+ this._resetTracking();
1208
1210
  }
1209
1211
  _accepts(pointerType) {
1210
1212
  return this._pointerTypes.includes(pointerType);
@@ -1252,12 +1254,21 @@ class IgxTouchManager {
1252
1254
  }
1253
1255
  };
1254
1256
  }
1257
+ _canStartPan(event) {
1258
+ if (event.distance < this._panThreshold) {
1259
+ return false;
1260
+ }
1261
+ if (this._panAxis === 'horizontal') {
1262
+ return Math.abs(event.deltaX) > Math.abs(event.deltaY);
1263
+ }
1264
+ if (this._panAxis === 'vertical') {
1265
+ return Math.abs(event.deltaY) > Math.abs(event.deltaX);
1266
+ }
1267
+ return true;
1268
+ }
1255
1269
  /** Stops tracking the current gesture and best-effort releases the pointer capture. */
1256
1270
  _stopTracking(pointerId) {
1257
- this._tracking = false;
1258
- this._panStarted = false;
1259
- this._pointerId = null;
1260
- this._startTarget = null;
1271
+ this._resetTracking();
1261
1272
  if (this._setPointerCapture && typeof this.target.releasePointerCapture === 'function') {
1262
1273
  try {
1263
1274
  this.target.releasePointerCapture(pointerId);
@@ -1268,6 +1279,12 @@ class IgxTouchManager {
1268
1279
  }
1269
1280
  }
1270
1281
  }
1282
+ _resetTracking() {
1283
+ this._tracking = false;
1284
+ this._panStarted = false;
1285
+ this._pointerId = null;
1286
+ this._startTarget = null;
1287
+ }
1271
1288
  }
1272
1289
 
1273
1290
  /* csSuppress */