Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
85 changes: 0 additions & 85 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

34 changes: 31 additions & 3 deletions projects/igniteui-angular/core/src/core/touch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,14 @@ export interface IgxGestureEvent {
* @internal
*/
export interface IgxTouchManagerCallbacks {
/** Fired on pointer down once the pointer type passes the configured filter, before any movement. */
pointerDown?: (event: IgxGestureEvent) => void;
/**
* Fired on pointer down once the pointer type passes the configured filter, before any movement.
*
* Return `false` to veto the gesture (e.g. when the touch does not start in an active zone).
* The manager then stops tracking immediately and best-effort releases the pointer capture, so
* normal page/component scrolling is not blocked by the `touchmove` listener.
*/
pointerDown?: (event: IgxGestureEvent) => boolean | void;
/** Fired on the first pointer move of a tracked gesture, once movement begins (mirrors Hammer's `panstart`). */
panStart?: (event: IgxGestureEvent) => void;
/** Fired on each pointer move while a gesture is tracked. */
Expand Down Expand Up @@ -211,7 +217,12 @@ export class IgxTouchManager {
}
}

this.callbacks.pointerDown?.(this._createEvent(event));
// Let the consumer veto the gesture (e.g. the touch did not start in an active
// zone). Returning `false` stops tracking immediately so the `touchmove` listener
// does not block normal scrolling and other gestures are not interfered with.
if (this.callbacks.pointerDown?.(this._createEvent(event)) === false) {
this._stopTracking(event.pointerId);
}
Comment on lines +220 to +225
};

private _onPointerMove = (event: PointerEvent) => {
Expand Down Expand Up @@ -265,4 +276,21 @@ export class IgxTouchManager {
event.preventDefault();
}
}

/** Stops tracking the current gesture and best-effort releases the pointer capture. */
private _stopTracking(pointerId: number): void {
this._tracking = false;
this._panStarted = false;
this._pointerId = null;
this._startTarget = null;

if (this._setPointerCapture && typeof (this.target as Element).releasePointerCapture === 'function') {
try {
(this.target as Element).releasePointerCapture(pointerId);
} catch {
// `releasePointerCapture` can throw when the pointer is no longer captured.
// Releasing is a best-effort cleanup, so ignore it.
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -755,9 +755,9 @@ export class IgxNavigationDrawerComponent implements
}
};

private panStart = (evt: IgxGestureEvent) => {
private panStart = (evt: IgxGestureEvent): boolean => {
if (!this.enableGestures || this.pin || evt.pointerType !== 'touch') {
return;
return false;
}
const startPosition = this.position === 'right' ? this.getWindowWidth() - (evt.center.x + evt.distance)
: evt.center.x - evt.distance;
Expand All @@ -778,7 +778,13 @@ export class IgxNavigationDrawerComponent implements
// slide reveals the full panel instead of just its padding/border.
this.renderer.setStyle(this.drawer, 'width', `${this.getExpectedWidth(false)}px`);
}
return true;
}

// The touch did not start in the edge zone (and the drawer is closed), so this
// gesture should be ignored. Returning `false` lets the touch manager stop
// tracking immediately and not interfere with normal page scrolling.
return false;
};

private pan = (evt: IgxGestureEvent) => {
Expand Down
Loading