Skip to content

Commit 8508d38

Browse files
chore: harden pinch helper utilities
Co-authored-by: siarheihuzarevich <[email protected]>
1 parent 5ce35bb commit 8508d38

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

projects/f-flow/src/f-zoom/f-zoom.directive.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ import { isNode } from '../f-node';
3232
import { EFZoomDirection } from './e-f-zoom-direction';
3333
import { EventExtensions } from '../drag-toolkit';
3434

35+
// Align pinch distance scaling with wheel delta normalization to keep zoom sensitivity consistent.
3536
const PINCH_NORMALIZATION_FACTOR = 100;
3637
const PINCH_MOVEMENT_THRESHOLD = 0.5;
3738
const NORMALIZED_MIN = 0.1;
@@ -226,6 +227,10 @@ export class FZoomDirective extends FZoomBase implements OnInit, AfterViewInit,
226227
}
227228

228229
private _getTouchDistance(touches: TouchList): number {
230+
if (touches.length < 2) {
231+
return 0;
232+
}
233+
229234
const firstTouch = touches[0];
230235
const secondTouch = touches[1];
231236

@@ -236,6 +241,10 @@ export class FZoomDirective extends FZoomBase implements OnInit, AfterViewInit,
236241
}
237242

238243
private _getTouchCenter(touches: TouchList): IPoint {
244+
if (touches.length < 2) {
245+
return PointExtensions.initialize();
246+
}
247+
239248
const firstTouch = touches[0];
240249
const secondTouch = touches[1];
241250

0 commit comments

Comments
 (0)