@sobree/core 0.1.5 → 0.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.
@@ -36,6 +36,12 @@ export interface ViewportOptions {
36
36
  * The point under the cursor stays under the cursor (zoom-to-cursor).
37
37
  * - Pan: wheel without modifiers — two-finger trackpad scroll deltas move
38
38
  * the stage. Also supports click-drag with middle mouse or space.
39
+ * - Touch (mobile): one-finger drag pans (after a small slop so taps
40
+ * still place the caret); two-finger pinch zooms anchored at the
41
+ * finger midpoint, and moving both fingers pans. Mouse/pen
42
+ * pointers are deliberately excluded — mouse drag is text
43
+ * selection. The container has `touch-action: none`, so without
44
+ * these handlers touch devices could neither scroll nor zoom.
39
45
  */
40
46
  export declare class Viewport {
41
47
  readonly container: HTMLElement;
@@ -75,6 +81,27 @@ export declare class Viewport {
75
81
  * sustained horizontal motion.
76
82
  */
77
83
  private horizontalLock;
84
+ /** Live touch pointers (pointerId → last client position). Mouse and
85
+ * pen never enter this map — their drag is text selection, not pan. */
86
+ private readonly touchPoints;
87
+ /** `idle` → no touches; `tap` → one finger down, within slop (a tap
88
+ * must still reach the editor to place the caret); `pan` → one finger
89
+ * past slop; `pinch` → two fingers. */
90
+ private touchMode;
91
+ /** First touch's start position — slop is measured from here. */
92
+ private touchStartX;
93
+ private touchStartY;
94
+ /** Finger distance and scale captured when a pinch begins. */
95
+ private pinchStartDist;
96
+ private pinchStartScale;
97
+ private readonly onPointerDown;
98
+ private readonly onPointerMove;
99
+ private readonly onPointerEnd;
100
+ private readonly onClickCapture;
101
+ /** Set when a pan/pinch actually moved the stage — the synthetic click
102
+ * browsers fire after the touch sequence must not reach the editor
103
+ * (it would teleport the caret to wherever the drag ended). */
104
+ private suppressNextClick;
78
105
  constructor(container: HTMLElement, options?: ViewportOptions);
79
106
  /** Reset pan to origin and scale to 1. */
80
107
  reset(): void;
@@ -103,6 +130,10 @@ export declare class Viewport {
103
130
  zoomTo(nextScale: number, clientX: number, clientY: number): void;
104
131
  destroy(): void;
105
132
  private handleWheel;
133
+ private handleTouchDown;
134
+ private handleTouchMove;
135
+ private handleTouchEnd;
136
+ private beginPinch;
106
137
  /**
107
138
  * Axis-lock for pan gestures:
108
139
  * - Within a gesture (events ≤ GESTURE_GAP_MS apart), a clear dominant