@zoompinch/core 0.0.27 → 0.0.28
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.
- package/dist/zoompinch-core.es.js +118 -105
- package/dist/zoompinch-core.umd.js +1 -1
- package/dist/zoompinch.d.ts +4 -0
- package/package.json +1 -1
|
@@ -1,58 +1,63 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
function
|
|
1
|
+
var z = Object.defineProperty;
|
|
2
|
+
var F = (o, l, t) => l in o ? z(o, l, { enumerable: !0, configurable: !0, writable: !0, value: t }) : o[l] = t;
|
|
3
|
+
var u = (o, l, t) => F(o, typeof l != "symbol" ? l + "" : l, t);
|
|
4
|
+
function x(o) {
|
|
5
5
|
return o * Math.PI / 180;
|
|
6
6
|
}
|
|
7
|
-
function C(o,
|
|
8
|
-
return Math.min(Math.max(o,
|
|
7
|
+
function C(o, l, t) {
|
|
8
|
+
return Math.min(Math.max(o, l), t);
|
|
9
9
|
}
|
|
10
|
-
function w(o,
|
|
11
|
-
const [
|
|
10
|
+
function w(o, l, t) {
|
|
11
|
+
const [e, s] = o, [a, n] = l, r = Math.cos(t) * (e - a) - Math.sin(t) * (s - n) + a, i = Math.sin(t) * (e - a) + Math.cos(t) * (s - n) + n;
|
|
12
12
|
return [r, i];
|
|
13
13
|
}
|
|
14
|
-
function Y(o,
|
|
15
|
-
const t = Math.pow(10,
|
|
14
|
+
function Y(o, l) {
|
|
15
|
+
const t = Math.pow(10, l);
|
|
16
16
|
return Math.round(o * t) / t;
|
|
17
17
|
}
|
|
18
|
-
function
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
18
|
+
function I(o) {
|
|
19
|
+
if (o.ctrlKey) {
|
|
20
|
+
const { deltaY: t, deltaMode: e, ctrlKey: s } = o, a = Math.abs(t), n = a === 120 || a === 100 || a === 3, r = t % 1 !== 0, i = e === 0;
|
|
21
|
+
return s ? a < 50 && i || r : !n && (r || i && a < 50);
|
|
22
|
+
} else {
|
|
23
|
+
var l = !1;
|
|
24
|
+
return o.wheelDeltaY ? o.wheelDeltaY === o.deltaY * -3 && (l = !0) : o.deltaMode === 0 && (l = !0), l;
|
|
25
|
+
}
|
|
25
26
|
}
|
|
26
|
-
function
|
|
27
|
-
let a = o.left -
|
|
28
|
-
const r = Math.cos(-
|
|
29
|
-
let c = a * r - n * i,
|
|
30
|
-
const
|
|
31
|
-
return c /=
|
|
27
|
+
function W(o, l, t, e, s) {
|
|
28
|
+
let a = o.left - l, n = o.top - t;
|
|
29
|
+
const r = Math.cos(-s), i = Math.sin(-s);
|
|
30
|
+
let c = a * r - n * i, h = a * i + n * r;
|
|
31
|
+
const d = o.width / e, p = o.height / e;
|
|
32
|
+
return c /= e, h /= e, { x: Y(c, 4), y: Y(h, 4), width: Y(d, 4), height: Y(p, 4) };
|
|
32
33
|
}
|
|
33
|
-
class
|
|
34
|
-
constructor(t,
|
|
34
|
+
class D extends EventTarget {
|
|
35
|
+
constructor(t, e, s, a, n, r, i = 0.1, c = 10, h = !1, d = !0) {
|
|
35
36
|
super();
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
this
|
|
46
|
-
|
|
37
|
+
u(this, "wrapperBounds");
|
|
38
|
+
u(this, "canvasBounds");
|
|
39
|
+
u(this, "translateSpeed", 1);
|
|
40
|
+
u(this, "zoomSpeed", 1);
|
|
41
|
+
u(this, "translateSpeedAppleTrackpad", 1);
|
|
42
|
+
u(this, "zoomSpeedAppleTrackpad", 1);
|
|
43
|
+
u(this, "gestureStartRotate", 0);
|
|
44
|
+
u(this, "dragStart", null);
|
|
45
|
+
u(this, "dragStartFrozenX", null);
|
|
46
|
+
u(this, "dragStartFrozenY", null);
|
|
47
|
+
u(this, "touchStarts", null);
|
|
48
|
+
u(this, "touchStartTranslateX", 0);
|
|
49
|
+
u(this, "touchStartTranslateY", 0);
|
|
50
|
+
this.element = t, this.offset = e, this.translateX = s, this.translateY = a, this.scale = n, this.rotate = r, this.minScale = i, this.maxScale = c, this.clampBounds = h, this.rotation = d;
|
|
51
|
+
const p = new ResizeObserver(() => {
|
|
47
52
|
const { x: g, y: m, width: S, height: v } = this.element.getBoundingClientRect();
|
|
48
53
|
this.wrapperBounds = { x: g, y: m, width: S, height: v }, this.update();
|
|
49
|
-
}),
|
|
50
|
-
const { x: g, y: m, width: S, height: v } =
|
|
54
|
+
}), f = new ResizeObserver(() => {
|
|
55
|
+
const { x: g, y: m, width: S, height: v } = W(this.canvasElement.getBoundingClientRect(), this.renderingTranslateX, this.renderingTranslateY, this.renderinScale, this.renderingRotate);
|
|
51
56
|
this.canvasBounds = { x: g, y: m, width: S, height: v }, this.update();
|
|
52
57
|
});
|
|
53
58
|
requestAnimationFrame(() => {
|
|
54
59
|
this.wrapperBounds = this.element.getBoundingClientRect(), this.canvasBounds = this.canvasElement.getBoundingClientRect(), this.update(), this.dispatchEvent(new Event("init"));
|
|
55
|
-
}),
|
|
60
|
+
}), f.observe(this.canvasElement), p.observe(this.element);
|
|
56
61
|
}
|
|
57
62
|
get canvasElement() {
|
|
58
63
|
return this.element.querySelector(".canvas");
|
|
@@ -82,22 +87,22 @@ class E extends EventTarget {
|
|
|
82
87
|
}
|
|
83
88
|
// The clamping is an explicit user intention
|
|
84
89
|
// The reason is that we do not want side effects when toggling the clamp
|
|
85
|
-
setTranslateFromUserGesture(t,
|
|
90
|
+
setTranslateFromUserGesture(t, e) {
|
|
86
91
|
if (this.clampBounds) {
|
|
87
|
-
const
|
|
88
|
-
this.translateX =
|
|
92
|
+
const s = this.clampTranslate({ translateX: t, translateY: e, scale: this.scale, rotate: this.rotate });
|
|
93
|
+
this.translateX = s.translateX, this.translateY = s.translateY, this.rotate = 0;
|
|
89
94
|
} else
|
|
90
|
-
this.translateX = t, this.translateY =
|
|
95
|
+
this.translateX = t, this.translateY = e;
|
|
91
96
|
}
|
|
92
97
|
handleGesturestart(t) {
|
|
93
98
|
this.gestureStartRotate = this.rotate;
|
|
94
99
|
}
|
|
95
100
|
handleGesturechange(t) {
|
|
96
|
-
const { clientX:
|
|
101
|
+
const { clientX: e, clientY: s } = t, a = t.rotation;
|
|
97
102
|
if (a === 0 || !this.rotation)
|
|
98
103
|
return;
|
|
99
|
-
const n = this.normalizeClientCoords(
|
|
100
|
-
this.rotateCanvas(n[0], n[1], this.gestureStartRotate +
|
|
104
|
+
const n = this.normalizeClientCoords(e, s);
|
|
105
|
+
this.rotateCanvas(n[0], n[1], this.gestureStartRotate + x(a));
|
|
101
106
|
}
|
|
102
107
|
handleGestureend(t) {
|
|
103
108
|
}
|
|
@@ -109,28 +114,36 @@ class E extends EventTarget {
|
|
|
109
114
|
}
|
|
110
115
|
handleMousemove(t) {
|
|
111
116
|
if (t.preventDefault(), this.dragStart && this.dragStartFrozenX !== null && this.dragStartFrozenY !== null) {
|
|
112
|
-
const
|
|
117
|
+
const e = t.clientX - this.dragStart[0], s = t.clientY - this.dragStart[1], a = this.dragStartFrozenX - -e, n = this.dragStartFrozenY - -s;
|
|
113
118
|
this.setTranslateFromUserGesture(a, n), this.update();
|
|
114
119
|
}
|
|
115
120
|
}
|
|
116
121
|
handleWheel(t) {
|
|
117
|
-
let { deltaX:
|
|
118
|
-
const n =
|
|
119
|
-
|
|
120
|
-
const
|
|
122
|
+
let { deltaX: e, deltaY: s, ctrlKey: a } = t;
|
|
123
|
+
const n = I(t);
|
|
124
|
+
n || (Math.abs(s) >= 100 && (s = Math.sign(s) * (Math.abs(s) / 120)), Math.abs(e) >= 100 && (e = Math.sign(e) * (Math.abs(e) / 120)));
|
|
125
|
+
const r = this.scale;
|
|
121
126
|
if (a) {
|
|
122
|
-
const
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
127
|
+
const i = n ? 0.01 * this.zoomSpeedAppleTrackpad : 0.1 * this.zoomSpeed, c = 1 + -s * i;
|
|
128
|
+
let h = r * c;
|
|
129
|
+
if (h = C(h, this.minScale, this.maxScale), (h === this.minScale || h === this.maxScale) && (h === this.minScale && c < 1 || h === this.maxScale && c > 1)) {
|
|
130
|
+
t.preventDefault();
|
|
131
|
+
return;
|
|
132
|
+
}
|
|
133
|
+
const d = this.relativeWrapperCoordinatesFromClientCoords(t.clientX, t.clientY), [p, f] = this.calcProjectionTranslate(h, d, this.normalizeMatrixCoordinates(t.clientX, t.clientY));
|
|
134
|
+
this.setTranslateFromUserGesture(p, f), this.scale = h;
|
|
135
|
+
} else {
|
|
136
|
+
const i = n ? 1 * this.translateSpeedAppleTrackpad : 25 * this.translateSpeed;
|
|
137
|
+
this.setTranslateFromUserGesture(this.translateX - e * i, this.translateY - s * i);
|
|
138
|
+
}
|
|
126
139
|
this.update(), t.preventDefault();
|
|
127
140
|
}
|
|
128
141
|
freezeTouches(t) {
|
|
129
|
-
return Array.from(t).map((
|
|
130
|
-
const
|
|
142
|
+
return Array.from(t).map((e) => {
|
|
143
|
+
const s = this.clientCoordsToWrapperCoords(e.clientX, e.clientY);
|
|
131
144
|
return {
|
|
132
|
-
client: [
|
|
133
|
-
canvasRel: this.getCanvasCoordsRel(
|
|
145
|
+
client: [e.clientX, e.clientY],
|
|
146
|
+
canvasRel: this.getCanvasCoordsRel(s[0], s[1])
|
|
134
147
|
};
|
|
135
148
|
});
|
|
136
149
|
}
|
|
@@ -139,20 +152,20 @@ class E extends EventTarget {
|
|
|
139
152
|
}
|
|
140
153
|
handleTouchmove(t) {
|
|
141
154
|
t.preventDefault();
|
|
142
|
-
const
|
|
155
|
+
const e = Array.from(t.touches).map((s) => this.clientCoordsToWrapperCoords(s.clientX, s.clientY));
|
|
143
156
|
if (this.touchStarts) {
|
|
144
|
-
if (
|
|
145
|
-
const
|
|
157
|
+
if (e.length >= 2 && this.touchStarts.length >= 2) {
|
|
158
|
+
const s = [this.touchStarts[0].canvasRel[0] * this.canvasBounds.width, this.touchStarts[0].canvasRel[1] * this.canvasBounds.height], a = [this.touchStarts[1].canvasRel[0] * this.canvasBounds.width, this.touchStarts[1].canvasRel[1] * this.canvasBounds.height], n = Math.sqrt(Math.pow(s[0] - a[0], 2) + Math.pow(s[1] - a[1], 2)), r = Math.sqrt(Math.pow(e[0][0] - e[1][0], 2) + Math.pow(e[0][1] - e[1][1], 2)) / this.naturalScale, i = C(r / n, this.minScale, this.maxScale), c = [e[0][0] / this.wrapperInnerWidth, e[0][1] / this.wrapperInnerHeight], h = this.touchStarts[0].canvasRel, [d, p] = this.calcProjectionTranslate(i, c, h, 0);
|
|
146
159
|
if (this.rotation) {
|
|
147
|
-
let
|
|
148
|
-
const S = Math.atan2(a[1] -
|
|
149
|
-
m = Math.atan2(
|
|
150
|
-
const T = (
|
|
151
|
-
|
|
160
|
+
let f = 0, g = 0, m = 0;
|
|
161
|
+
const S = Math.atan2(a[1] - s[1], a[0] - s[0]);
|
|
162
|
+
m = Math.atan2(e[1][1] - e[0][1], e[1][0] - e[0][0]) - S;
|
|
163
|
+
const T = (B, P) => [this.offset.left + this.canvasBounds.width * B * this.naturalScale * i + d, this.offset.top + this.canvasBounds.height * P * this.naturalScale * i + p], X = T(0, 0), M = T(this.touchStarts[0].canvasRel[0], this.touchStarts[0].canvasRel[1]), R = w(X, M, m);
|
|
164
|
+
f = R[0] - X[0], g = R[1] - X[1], this.scale = i, this.rotate = m, this.setTranslateFromUserGesture(d + f, p + g);
|
|
152
165
|
} else
|
|
153
|
-
this.scale = i, this.setTranslateFromUserGesture(
|
|
166
|
+
this.scale = i, this.setTranslateFromUserGesture(d, p);
|
|
154
167
|
} else {
|
|
155
|
-
const
|
|
168
|
+
const s = t.touches[0].clientX - this.touchStarts[0].client[0], a = t.touches[0].clientY - this.touchStarts[0].client[1], n = this.touchStartTranslateX + s, r = this.touchStartTranslateY + a;
|
|
156
169
|
this.setTranslateFromUserGesture(n, r);
|
|
157
170
|
}
|
|
158
171
|
this.update();
|
|
@@ -161,57 +174,57 @@ class E extends EventTarget {
|
|
|
161
174
|
handleTouchend(t) {
|
|
162
175
|
t.touches.length === 0 ? this.touchStarts = null : (this.touchStarts = this.freezeTouches(t.touches), this.touchStartTranslateX = this.translateX, this.touchStartTranslateY = this.translateY);
|
|
163
176
|
}
|
|
164
|
-
calcProjectionTranslate(t,
|
|
165
|
-
const n = this.canvasBounds.width * this.naturalScale, r = this.canvasBounds.height * this.naturalScale, i =
|
|
166
|
-
return [
|
|
177
|
+
calcProjectionTranslate(t, e, s, a) {
|
|
178
|
+
const n = this.canvasBounds.width * this.naturalScale, r = this.canvasBounds.height * this.naturalScale, i = s[0] * n * t, c = s[1] * r * t, h = w([i, c], [0, 0], a ?? this.rotate), d = e[0] * this.wrapperInnerWidth, p = e[1] * this.wrapperInnerHeight, f = d - h[0], g = p - h[1];
|
|
179
|
+
return [f, g];
|
|
167
180
|
}
|
|
168
|
-
applyTransform(t,
|
|
169
|
-
const a = this.calcProjectionTranslate(t,
|
|
181
|
+
applyTransform(t, e, s) {
|
|
182
|
+
const a = this.calcProjectionTranslate(t, e, s, 0);
|
|
170
183
|
this.scale = t, this.setTranslateFromUserGesture(a[0], a[1]), this.update();
|
|
171
184
|
}
|
|
172
|
-
composeRelPoint(t,
|
|
173
|
-
|
|
174
|
-
const i = [this.offset.left, this.offset.top], c = [this.offset.left + this.canvasBounds.width * (
|
|
175
|
-
return [
|
|
185
|
+
composeRelPoint(t, e, s, a, n, r) {
|
|
186
|
+
s = s ?? this.scale, a = a ?? this.translateX, n = n ?? this.translateY, r = r ?? this.rotate;
|
|
187
|
+
const i = [this.offset.left, this.offset.top], c = [this.offset.left + this.canvasBounds.width * (s * this.naturalScale) * t, this.offset.top + this.canvasBounds.height * (s * this.naturalScale) * e], h = w(c, i, r);
|
|
188
|
+
return [h[0] + a, h[1] + n];
|
|
176
189
|
}
|
|
177
|
-
composePoint(t,
|
|
178
|
-
const
|
|
179
|
-
return this.composeRelPoint(
|
|
190
|
+
composePoint(t, e) {
|
|
191
|
+
const s = t / this.canvasBounds.width, a = e / this.canvasBounds.height;
|
|
192
|
+
return this.composeRelPoint(s, a);
|
|
180
193
|
}
|
|
181
|
-
getAnchorOffset(t,
|
|
194
|
+
getAnchorOffset(t, e, s, a, n = [0.5, 0.5]) {
|
|
182
195
|
const r = this.calcProjectionTranslate(t, n, n, 0), i = [
|
|
183
196
|
this.offset.left + r[0] + this.canvasBounds.width * (t * this.naturalScale) * n[0],
|
|
184
197
|
this.offset.top + r[1] + this.canvasBounds.height * (t * this.naturalScale) * n[1]
|
|
185
|
-
], c = this.composeRelPoint(n[0], n[1], t,
|
|
186
|
-
return [
|
|
198
|
+
], c = this.composeRelPoint(n[0], n[1], t, e, s, a), h = c[0] - i[0], d = c[1] - i[1];
|
|
199
|
+
return [h, d];
|
|
187
200
|
}
|
|
188
201
|
// Converts absolute inner wrapper coordinates to relative canvas coordinates (0-1, 0-1)
|
|
189
|
-
getCanvasCoordsRel(t,
|
|
190
|
-
const
|
|
202
|
+
getCanvasCoordsRel(t, e) {
|
|
203
|
+
const s = [0, 0], a = [t - this.translateX, e - this.translateY], n = w(a, s, -this.rotate), r = [n[0] / this.renderinScale, n[1] / this.renderinScale];
|
|
191
204
|
return [r[0] / this.canvasBounds.width, r[1] / this.canvasBounds.height];
|
|
192
205
|
}
|
|
193
206
|
// Converts absolute client to coordinates to absolute inner-wrapper coorinates
|
|
194
|
-
clientCoordsToWrapperCoords(t,
|
|
195
|
-
return [t - this.wrapperInnerX,
|
|
207
|
+
clientCoordsToWrapperCoords(t, e) {
|
|
208
|
+
return [t - this.wrapperInnerX, e - this.wrapperInnerY];
|
|
196
209
|
}
|
|
197
210
|
// Converts absolute client coordinates to relative wrapper coordinates (0-1, 0-1)
|
|
198
|
-
relativeWrapperCoordinatesFromClientCoords(t,
|
|
199
|
-
const [
|
|
200
|
-
return [
|
|
211
|
+
relativeWrapperCoordinatesFromClientCoords(t, e) {
|
|
212
|
+
const [s, a] = this.clientCoordsToWrapperCoords(t, e);
|
|
213
|
+
return [s / this.wrapperInnerWidth, a / this.wrapperInnerHeight];
|
|
201
214
|
}
|
|
202
215
|
// Converts client coordinates to relative canvas coordinates (0-1, 0-1)
|
|
203
|
-
normalizeMatrixCoordinates(t,
|
|
204
|
-
const
|
|
205
|
-
return this.getCanvasCoordsRel(
|
|
216
|
+
normalizeMatrixCoordinates(t, e) {
|
|
217
|
+
const s = this.clientCoordsToWrapperCoords(t, e);
|
|
218
|
+
return this.getCanvasCoordsRel(s[0], s[1]);
|
|
206
219
|
}
|
|
207
220
|
// Converts client coordinates to absolute canvas coordinates
|
|
208
|
-
normalizeClientCoords(t,
|
|
209
|
-
const [
|
|
210
|
-
return [
|
|
221
|
+
normalizeClientCoords(t, e) {
|
|
222
|
+
const [s, a] = this.normalizeMatrixCoordinates(t, e);
|
|
223
|
+
return [s * this.canvasBounds.width, a * this.canvasBounds.height];
|
|
211
224
|
}
|
|
212
|
-
rotateCanvas(t,
|
|
213
|
-
const a = t / this.canvasBounds.width, n =
|
|
214
|
-
this.setTranslateFromUserGesture(i[0] - r[0], i[1] - r[1]), this.rotate =
|
|
225
|
+
rotateCanvas(t, e, s) {
|
|
226
|
+
const a = t / this.canvasBounds.width, n = e / this.canvasBounds.height, r = this.composeRelPoint(a, n, this.scale, 0, 0, s), i = this.composeRelPoint(a, n);
|
|
227
|
+
this.setTranslateFromUserGesture(i[0] - r[0], i[1] - r[1]), this.rotate = s, this.update();
|
|
215
228
|
}
|
|
216
229
|
get renderinScale() {
|
|
217
230
|
return this.naturalScale * this.scale;
|
|
@@ -225,11 +238,11 @@ class E extends EventTarget {
|
|
|
225
238
|
get renderingRotate() {
|
|
226
239
|
return this.rotate;
|
|
227
240
|
}
|
|
228
|
-
clampTranslate(t,
|
|
229
|
-
const
|
|
241
|
+
clampTranslate(t, e = [0.5, 0.5]) {
|
|
242
|
+
const s = this.canvasBounds.width * this.naturalScale * t.scale, a = this.canvasBounds.height * this.naturalScale * t.scale, n = s - this.wrapperInnerWidth, r = a - this.wrapperInnerHeight, i = n > 0 ? -n : 0, c = Math.min(0, Math.max(t.translateX, i)), h = r > 0 ? -r : 0, d = Math.min(0, Math.max(t.translateY, h)), p = -Math.min(0, n) * e[0], f = -Math.min(0, r) * e[1];
|
|
230
243
|
return {
|
|
231
|
-
translateX: c +
|
|
232
|
-
translateY:
|
|
244
|
+
translateX: c + p,
|
|
245
|
+
translateY: d + f
|
|
233
246
|
};
|
|
234
247
|
}
|
|
235
248
|
update() {
|
|
@@ -239,5 +252,5 @@ class E extends EventTarget {
|
|
|
239
252
|
}
|
|
240
253
|
}
|
|
241
254
|
export {
|
|
242
|
-
|
|
255
|
+
D as Zoompinch
|
|
243
256
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(f,d){typeof exports=="object"&&typeof module<"u"?d(exports):typeof define=="function"&&define.amd?define(["exports"],d):(f=typeof globalThis<"u"?globalThis:f||self,d(f.Zoompinch={}))})(this,(function(f){"use strict";var D=Object.defineProperty;var b=(f,d,v)=>d in f?D(f,d,{enumerable:!0,configurable:!0,writable:!0,value:v}):f[d]=v;var m=(f,d,v)=>b(f,typeof d!="symbol"?d+"":d,v);function d(o){return o*Math.PI/180}function v(o,u,t){return Math.min(Math.max(o,u),t)}function X(o,u,t){const[e,s]=o,[a,n]=u,r=Math.cos(t)*(e-a)-Math.sin(t)*(s-n)+a,i=Math.sin(t)*(e-a)+Math.cos(t)*(s-n)+n;return[r,i]}function T(o,u){const t=Math.pow(10,u);return Math.round(o*t)/t}function x(o){var u=!1;return o.wheelDeltaY?o.wheelDeltaY===o.deltaY*-3&&(u=!0):o.deltaMode===0&&(u=!0),u}function B(o,u){const t=u.find(e=>o%e===0);return t?o/t:1}function F(o,u,t,e,s){let a=o.left-u,n=o.top-t;const r=Math.cos(-s),i=Math.sin(-s);let l=a*r-n*i,h=a*i+n*r;const c=o.width/e,p=o.height/e;return l/=e,h/=e,{x:T(l,4),y:T(h,4),width:T(c,4),height:T(p,4)}}class I extends EventTarget{constructor(t,e,s,a,n,r,i=.1,l=10,h=!1,c=!0){super();m(this,"wrapperBounds");m(this,"canvasBounds");m(this,"gestureStartRotate",0);m(this,"dragStart",null);m(this,"dragStartFrozenX",null);m(this,"dragStartFrozenY",null);m(this,"touchStarts",null);m(this,"touchStartTranslateX",0);m(this,"touchStartTranslateY",0);this.element=t,this.offset=e,this.translateX=s,this.translateY=a,this.scale=n,this.rotate=r,this.minScale=i,this.maxScale=l,this.clampBounds=h,this.rotation=c;const p=new ResizeObserver(()=>{const{x:S,y:w,width:Y,height:R}=this.element.getBoundingClientRect();this.wrapperBounds={x:S,y:w,width:Y,height:R},this.update()}),g=new ResizeObserver(()=>{const{x:S,y:w,width:Y,height:R}=F(this.canvasElement.getBoundingClientRect(),this.renderingTranslateX,this.renderingTranslateY,this.renderinScale,this.renderingRotate);this.canvasBounds={x:S,y:w,width:Y,height:R},this.update()});requestAnimationFrame(()=>{this.wrapperBounds=this.element.getBoundingClientRect(),this.canvasBounds=this.canvasElement.getBoundingClientRect(),this.update(),this.dispatchEvent(new Event("init"))}),g.observe(this.canvasElement),p.observe(this.element)}get canvasElement(){return this.element.querySelector(".canvas")}get wrapperInnerX(){return this.wrapperBounds.x+this.offset.left}get wrapperInnerY(){return this.wrapperBounds.y+this.offset.top}get wrapperInnerWidth(){return this.wrapperBounds.width-this.offset.left-this.offset.right}get wrapperInnerHeight(){return this.wrapperBounds.height-this.offset.top-this.offset.bottom}get wrapperInnerRatio(){return this.wrapperInnerWidth/this.wrapperInnerHeight}get canvasNaturalRatio(){return this.canvasBounds.width/this.canvasBounds.height}get naturalScale(){return this.canvasNaturalRatio>=this.wrapperInnerRatio?this.wrapperInnerWidth/this.canvasBounds.width:this.wrapperInnerHeight/this.canvasBounds.height}setTranslateFromUserGesture(t,e){if(this.clampBounds){const s=this.clampTranslate({translateX:t,translateY:e,scale:this.scale,rotate:this.rotate});this.translateX=s.translateX,this.translateY=s.translateY,this.rotate=0}else this.translateX=t,this.translateY=e}handleGesturestart(t){this.gestureStartRotate=this.rotate}handleGesturechange(t){const{clientX:e,clientY:s}=t,a=t.rotation;if(a===0||!this.rotation)return;const n=this.normalizeClientCoords(e,s);this.rotateCanvas(n[0],n[1],this.gestureStartRotate+d(a))}handleGestureend(t){}handleMousedown(t){t.preventDefault(),this.dragStart=[t.clientX,t.clientY],this.dragStartFrozenX=this.translateX,this.dragStartFrozenY=this.translateY}handleMouseup(t){t.preventDefault(),this.dragStart=null,this.dragStartFrozenX=null,this.dragStartFrozenY=null}handleMousemove(t){if(t.preventDefault(),this.dragStart&&this.dragStartFrozenX!==null&&this.dragStartFrozenY!==null){const e=t.clientX-this.dragStart[0],s=t.clientY-this.dragStart[1],a=this.dragStartFrozenX- -e,n=this.dragStartFrozenY- -s;this.setTranslateFromUserGesture(a,n),this.update()}}handleWheel(t){let{deltaX:e,deltaY:s,ctrlKey:a}=t;const n=[120,100],r=2;x(t)||((Math.abs(e)===120||Math.abs(e)===200)&&(e=e/(100/r*B(e,n))*Math.sign(e)),(Math.abs(s)===120||Math.abs(s)===200)&&(s=s/(100/r*B(s,n))*Math.sign(s)));const i=this.scale;if(a){const l=-s/100*i,h=v(i+l,this.minScale,this.maxScale),c=this.relativeWrapperCoordinatesFromClientCoords(t.clientX,t.clientY),[p,g]=this.calcProjectionTranslate(h,c,this.normalizeMatrixCoordinates(t.clientX,t.clientY));this.setTranslateFromUserGesture(p,g),this.scale=h}else this.setTranslateFromUserGesture(this.translateX-e,this.translateY-s);this.update(),t.preventDefault()}freezeTouches(t){return Array.from(t).map(e=>{const s=this.clientCoordsToWrapperCoords(e.clientX,e.clientY);return{client:[e.clientX,e.clientY],canvasRel:this.getCanvasCoordsRel(s[0],s[1])}})}handleTouchstart(t){this.touchStarts=this.freezeTouches(t.touches),this.touchStartTranslateX=this.translateX,this.touchStartTranslateY=this.translateY,t.preventDefault()}handleTouchmove(t){t.preventDefault();const e=Array.from(t.touches).map(s=>this.clientCoordsToWrapperCoords(s.clientX,s.clientY));if(this.touchStarts){if(e.length>=2&&this.touchStarts.length>=2){const s=[this.touchStarts[0].canvasRel[0]*this.canvasBounds.width,this.touchStarts[0].canvasRel[1]*this.canvasBounds.height],a=[this.touchStarts[1].canvasRel[0]*this.canvasBounds.width,this.touchStarts[1].canvasRel[1]*this.canvasBounds.height],n=Math.sqrt(Math.pow(s[0]-a[0],2)+Math.pow(s[1]-a[1],2)),r=Math.sqrt(Math.pow(e[0][0]-e[1][0],2)+Math.pow(e[0][1]-e[1][1],2))/this.naturalScale,i=v(r/n,this.minScale,this.maxScale),l=[e[0][0]/this.wrapperInnerWidth,e[0][1]/this.wrapperInnerHeight],h=this.touchStarts[0].canvasRel,[c,p]=this.calcProjectionTranslate(i,l,h,0);if(this.rotation){let g=0,S=0,w=0;const Y=Math.atan2(a[1]-s[1],a[0]-s[0]);w=Math.atan2(e[1][1]-e[0][1],e[1][0]-e[0][0])-Y;const M=(y,z)=>[this.offset.left+this.canvasBounds.width*y*this.naturalScale*i+c,this.offset.top+this.canvasBounds.height*z*this.naturalScale*i+p],C=M(0,0),W=M(this.touchStarts[0].canvasRel[0],this.touchStarts[0].canvasRel[1]),P=X(C,W,w);g=P[0]-C[0],S=P[1]-C[1],this.scale=i,this.rotate=w,this.setTranslateFromUserGesture(c+g,p+S)}else this.scale=i,this.setTranslateFromUserGesture(c,p)}else{const s=t.touches[0].clientX-this.touchStarts[0].client[0],a=t.touches[0].clientY-this.touchStarts[0].client[1],n=this.touchStartTranslateX+s,r=this.touchStartTranslateY+a;this.setTranslateFromUserGesture(n,r)}this.update()}}handleTouchend(t){t.touches.length===0?this.touchStarts=null:(this.touchStarts=this.freezeTouches(t.touches),this.touchStartTranslateX=this.translateX,this.touchStartTranslateY=this.translateY)}calcProjectionTranslate(t,e,s,a){const n=this.canvasBounds.width*this.naturalScale,r=this.canvasBounds.height*this.naturalScale,i=s[0]*n*t,l=s[1]*r*t,h=X([i,l],[0,0],a??this.rotate),c=e[0]*this.wrapperInnerWidth,p=e[1]*this.wrapperInnerHeight,g=c-h[0],S=p-h[1];return[g,S]}applyTransform(t,e,s){const a=this.calcProjectionTranslate(t,e,s,0);this.scale=t,this.setTranslateFromUserGesture(a[0],a[1]),this.update()}composeRelPoint(t,e,s,a,n,r){s=s??this.scale,a=a??this.translateX,n=n??this.translateY,r=r??this.rotate;const i=[this.offset.left,this.offset.top],l=[this.offset.left+this.canvasBounds.width*(s*this.naturalScale)*t,this.offset.top+this.canvasBounds.height*(s*this.naturalScale)*e],h=X(l,i,r);return[h[0]+a,h[1]+n]}composePoint(t,e){const s=t/this.canvasBounds.width,a=e/this.canvasBounds.height;return this.composeRelPoint(s,a)}getAnchorOffset(t,e,s,a,n=[.5,.5]){const r=this.calcProjectionTranslate(t,n,n,0),i=[this.offset.left+r[0]+this.canvasBounds.width*(t*this.naturalScale)*n[0],this.offset.top+r[1]+this.canvasBounds.height*(t*this.naturalScale)*n[1]],l=this.composeRelPoint(n[0],n[1],t,e,s,a),h=l[0]-i[0],c=l[1]-i[1];return[h,c]}getCanvasCoordsRel(t,e){const s=[0,0],a=[t-this.translateX,e-this.translateY],n=X(a,s,-this.rotate),r=[n[0]/this.renderinScale,n[1]/this.renderinScale];return[r[0]/this.canvasBounds.width,r[1]/this.canvasBounds.height]}clientCoordsToWrapperCoords(t,e){return[t-this.wrapperInnerX,e-this.wrapperInnerY]}relativeWrapperCoordinatesFromClientCoords(t,e){const[s,a]=this.clientCoordsToWrapperCoords(t,e);return[s/this.wrapperInnerWidth,a/this.wrapperInnerHeight]}normalizeMatrixCoordinates(t,e){const s=this.clientCoordsToWrapperCoords(t,e);return this.getCanvasCoordsRel(s[0],s[1])}normalizeClientCoords(t,e){const[s,a]=this.normalizeMatrixCoordinates(t,e);return[s*this.canvasBounds.width,a*this.canvasBounds.height]}rotateCanvas(t,e,s){const a=t/this.canvasBounds.width,n=e/this.canvasBounds.height,r=this.composeRelPoint(a,n,this.scale,0,0,s),i=this.composeRelPoint(a,n);this.setTranslateFromUserGesture(i[0]-r[0],i[1]-r[1]),this.rotate=s,this.update()}get renderinScale(){return this.naturalScale*this.scale}get renderingTranslateX(){return this.offset.left+this.translateX}get renderingTranslateY(){return this.offset.top+this.translateY}get renderingRotate(){return this.rotate}clampTranslate(t,e=[.5,.5]){const s=this.canvasBounds.width*this.naturalScale*t.scale,a=this.canvasBounds.height*this.naturalScale*t.scale,n=s-this.wrapperInnerWidth,r=a-this.wrapperInnerHeight,i=n>0?-n:0,l=Math.min(0,Math.max(t.translateX,i)),h=r>0?-r:0,c=Math.min(0,Math.max(t.translateY,h)),p=-Math.min(0,n)*e[0],g=-Math.min(0,r)*e[1];return{translateX:l+p,translateY:c+g}}update(){this.canvasElement.style.transformOrigin="top left",this.canvasElement.style.transform=`translateX(${this.renderingTranslateX}px) translateY(${this.renderingTranslateY}px) scale(${this.renderinScale}) rotate(${this.renderingRotate}rad)`,this.dispatchEvent(new Event("update"))}destroy(){}}f.Zoompinch=I,Object.defineProperty(f,Symbol.toStringTag,{value:"Module"})}));
|
|
1
|
+
(function(f,u){typeof exports=="object"&&typeof module<"u"?u(exports):typeof define=="function"&&define.amd?define(["exports"],u):(f=typeof globalThis<"u"?globalThis:f||self,u(f.Zoompinch={}))})(this,(function(f){"use strict";var W=Object.defineProperty;var D=(f,u,v)=>u in f?W(f,u,{enumerable:!0,configurable:!0,writable:!0,value:v}):f[u]=v;var d=(f,u,v)=>D(f,typeof u!="symbol"?u+"":u,v);function u(h){return h*Math.PI/180}function v(h,g,t){return Math.min(Math.max(h,g),t)}function T(h,g,t){const[e,s]=h,[a,n]=g,r=Math.cos(t)*(e-a)-Math.sin(t)*(s-n)+a,i=Math.sin(t)*(e-a)+Math.cos(t)*(s-n)+n;return[r,i]}function X(h,g){const t=Math.pow(10,g);return Math.round(h*t)/t}function P(h){if(h.ctrlKey){const{deltaY:t,deltaMode:e,ctrlKey:s}=h,a=Math.abs(t),n=a===120||a===100||a===3,r=t%1!==0,i=e===0;return s?a<50&&i||r:!n&&(r||i&&a<50)}else{var g=!1;return h.wheelDeltaY?h.wheelDeltaY===h.deltaY*-3&&(g=!0):h.deltaMode===0&&(g=!0),g}}function z(h,g,t,e,s){let a=h.left-g,n=h.top-t;const r=Math.cos(-s),i=Math.sin(-s);let l=a*r-n*i,o=a*i+n*r;const c=h.width/e,p=h.height/e;return l/=e,o/=e,{x:X(l,4),y:X(o,4),width:X(c,4),height:X(p,4)}}class F extends EventTarget{constructor(t,e,s,a,n,r,i=.1,l=10,o=!1,c=!0){super();d(this,"wrapperBounds");d(this,"canvasBounds");d(this,"translateSpeed",1);d(this,"zoomSpeed",1);d(this,"translateSpeedAppleTrackpad",1);d(this,"zoomSpeedAppleTrackpad",1);d(this,"gestureStartRotate",0);d(this,"dragStart",null);d(this,"dragStartFrozenX",null);d(this,"dragStartFrozenY",null);d(this,"touchStarts",null);d(this,"touchStartTranslateX",0);d(this,"touchStartTranslateY",0);this.element=t,this.offset=e,this.translateX=s,this.translateY=a,this.scale=n,this.rotate=r,this.minScale=i,this.maxScale=l,this.clampBounds=o,this.rotation=c;const p=new ResizeObserver(()=>{const{x:S,y:w,width:Y,height:R}=this.element.getBoundingClientRect();this.wrapperBounds={x:S,y:w,width:Y,height:R},this.update()}),m=new ResizeObserver(()=>{const{x:S,y:w,width:Y,height:R}=z(this.canvasElement.getBoundingClientRect(),this.renderingTranslateX,this.renderingTranslateY,this.renderinScale,this.renderingRotate);this.canvasBounds={x:S,y:w,width:Y,height:R},this.update()});requestAnimationFrame(()=>{this.wrapperBounds=this.element.getBoundingClientRect(),this.canvasBounds=this.canvasElement.getBoundingClientRect(),this.update(),this.dispatchEvent(new Event("init"))}),m.observe(this.canvasElement),p.observe(this.element)}get canvasElement(){return this.element.querySelector(".canvas")}get wrapperInnerX(){return this.wrapperBounds.x+this.offset.left}get wrapperInnerY(){return this.wrapperBounds.y+this.offset.top}get wrapperInnerWidth(){return this.wrapperBounds.width-this.offset.left-this.offset.right}get wrapperInnerHeight(){return this.wrapperBounds.height-this.offset.top-this.offset.bottom}get wrapperInnerRatio(){return this.wrapperInnerWidth/this.wrapperInnerHeight}get canvasNaturalRatio(){return this.canvasBounds.width/this.canvasBounds.height}get naturalScale(){return this.canvasNaturalRatio>=this.wrapperInnerRatio?this.wrapperInnerWidth/this.canvasBounds.width:this.wrapperInnerHeight/this.canvasBounds.height}setTranslateFromUserGesture(t,e){if(this.clampBounds){const s=this.clampTranslate({translateX:t,translateY:e,scale:this.scale,rotate:this.rotate});this.translateX=s.translateX,this.translateY=s.translateY,this.rotate=0}else this.translateX=t,this.translateY=e}handleGesturestart(t){this.gestureStartRotate=this.rotate}handleGesturechange(t){const{clientX:e,clientY:s}=t,a=t.rotation;if(a===0||!this.rotation)return;const n=this.normalizeClientCoords(e,s);this.rotateCanvas(n[0],n[1],this.gestureStartRotate+u(a))}handleGestureend(t){}handleMousedown(t){t.preventDefault(),this.dragStart=[t.clientX,t.clientY],this.dragStartFrozenX=this.translateX,this.dragStartFrozenY=this.translateY}handleMouseup(t){t.preventDefault(),this.dragStart=null,this.dragStartFrozenX=null,this.dragStartFrozenY=null}handleMousemove(t){if(t.preventDefault(),this.dragStart&&this.dragStartFrozenX!==null&&this.dragStartFrozenY!==null){const e=t.clientX-this.dragStart[0],s=t.clientY-this.dragStart[1],a=this.dragStartFrozenX- -e,n=this.dragStartFrozenY- -s;this.setTranslateFromUserGesture(a,n),this.update()}}handleWheel(t){let{deltaX:e,deltaY:s,ctrlKey:a}=t;const n=P(t);n||(Math.abs(s)>=100&&(s=Math.sign(s)*(Math.abs(s)/120)),Math.abs(e)>=100&&(e=Math.sign(e)*(Math.abs(e)/120)));const r=this.scale;if(a){const i=n?.01*this.zoomSpeedAppleTrackpad:.1*this.zoomSpeed,l=1+-s*i;let o=r*l;if(o=v(o,this.minScale,this.maxScale),(o===this.minScale||o===this.maxScale)&&(o===this.minScale&&l<1||o===this.maxScale&&l>1)){t.preventDefault();return}const c=this.relativeWrapperCoordinatesFromClientCoords(t.clientX,t.clientY),[p,m]=this.calcProjectionTranslate(o,c,this.normalizeMatrixCoordinates(t.clientX,t.clientY));this.setTranslateFromUserGesture(p,m),this.scale=o}else{const i=n?1*this.translateSpeedAppleTrackpad:25*this.translateSpeed;this.setTranslateFromUserGesture(this.translateX-e*i,this.translateY-s*i)}this.update(),t.preventDefault()}freezeTouches(t){return Array.from(t).map(e=>{const s=this.clientCoordsToWrapperCoords(e.clientX,e.clientY);return{client:[e.clientX,e.clientY],canvasRel:this.getCanvasCoordsRel(s[0],s[1])}})}handleTouchstart(t){this.touchStarts=this.freezeTouches(t.touches),this.touchStartTranslateX=this.translateX,this.touchStartTranslateY=this.translateY,t.preventDefault()}handleTouchmove(t){t.preventDefault();const e=Array.from(t.touches).map(s=>this.clientCoordsToWrapperCoords(s.clientX,s.clientY));if(this.touchStarts){if(e.length>=2&&this.touchStarts.length>=2){const s=[this.touchStarts[0].canvasRel[0]*this.canvasBounds.width,this.touchStarts[0].canvasRel[1]*this.canvasBounds.height],a=[this.touchStarts[1].canvasRel[0]*this.canvasBounds.width,this.touchStarts[1].canvasRel[1]*this.canvasBounds.height],n=Math.sqrt(Math.pow(s[0]-a[0],2)+Math.pow(s[1]-a[1],2)),r=Math.sqrt(Math.pow(e[0][0]-e[1][0],2)+Math.pow(e[0][1]-e[1][1],2))/this.naturalScale,i=v(r/n,this.minScale,this.maxScale),l=[e[0][0]/this.wrapperInnerWidth,e[0][1]/this.wrapperInnerHeight],o=this.touchStarts[0].canvasRel,[c,p]=this.calcProjectionTranslate(i,l,o,0);if(this.rotation){let m=0,S=0,w=0;const Y=Math.atan2(a[1]-s[1],a[0]-s[0]);w=Math.atan2(e[1][1]-e[0][1],e[1][0]-e[0][0])-Y;const M=(y,I)=>[this.offset.left+this.canvasBounds.width*y*this.naturalScale*i+c,this.offset.top+this.canvasBounds.height*I*this.naturalScale*i+p],C=M(0,0),x=M(this.touchStarts[0].canvasRel[0],this.touchStarts[0].canvasRel[1]),B=T(C,x,w);m=B[0]-C[0],S=B[1]-C[1],this.scale=i,this.rotate=w,this.setTranslateFromUserGesture(c+m,p+S)}else this.scale=i,this.setTranslateFromUserGesture(c,p)}else{const s=t.touches[0].clientX-this.touchStarts[0].client[0],a=t.touches[0].clientY-this.touchStarts[0].client[1],n=this.touchStartTranslateX+s,r=this.touchStartTranslateY+a;this.setTranslateFromUserGesture(n,r)}this.update()}}handleTouchend(t){t.touches.length===0?this.touchStarts=null:(this.touchStarts=this.freezeTouches(t.touches),this.touchStartTranslateX=this.translateX,this.touchStartTranslateY=this.translateY)}calcProjectionTranslate(t,e,s,a){const n=this.canvasBounds.width*this.naturalScale,r=this.canvasBounds.height*this.naturalScale,i=s[0]*n*t,l=s[1]*r*t,o=T([i,l],[0,0],a??this.rotate),c=e[0]*this.wrapperInnerWidth,p=e[1]*this.wrapperInnerHeight,m=c-o[0],S=p-o[1];return[m,S]}applyTransform(t,e,s){const a=this.calcProjectionTranslate(t,e,s,0);this.scale=t,this.setTranslateFromUserGesture(a[0],a[1]),this.update()}composeRelPoint(t,e,s,a,n,r){s=s??this.scale,a=a??this.translateX,n=n??this.translateY,r=r??this.rotate;const i=[this.offset.left,this.offset.top],l=[this.offset.left+this.canvasBounds.width*(s*this.naturalScale)*t,this.offset.top+this.canvasBounds.height*(s*this.naturalScale)*e],o=T(l,i,r);return[o[0]+a,o[1]+n]}composePoint(t,e){const s=t/this.canvasBounds.width,a=e/this.canvasBounds.height;return this.composeRelPoint(s,a)}getAnchorOffset(t,e,s,a,n=[.5,.5]){const r=this.calcProjectionTranslate(t,n,n,0),i=[this.offset.left+r[0]+this.canvasBounds.width*(t*this.naturalScale)*n[0],this.offset.top+r[1]+this.canvasBounds.height*(t*this.naturalScale)*n[1]],l=this.composeRelPoint(n[0],n[1],t,e,s,a),o=l[0]-i[0],c=l[1]-i[1];return[o,c]}getCanvasCoordsRel(t,e){const s=[0,0],a=[t-this.translateX,e-this.translateY],n=T(a,s,-this.rotate),r=[n[0]/this.renderinScale,n[1]/this.renderinScale];return[r[0]/this.canvasBounds.width,r[1]/this.canvasBounds.height]}clientCoordsToWrapperCoords(t,e){return[t-this.wrapperInnerX,e-this.wrapperInnerY]}relativeWrapperCoordinatesFromClientCoords(t,e){const[s,a]=this.clientCoordsToWrapperCoords(t,e);return[s/this.wrapperInnerWidth,a/this.wrapperInnerHeight]}normalizeMatrixCoordinates(t,e){const s=this.clientCoordsToWrapperCoords(t,e);return this.getCanvasCoordsRel(s[0],s[1])}normalizeClientCoords(t,e){const[s,a]=this.normalizeMatrixCoordinates(t,e);return[s*this.canvasBounds.width,a*this.canvasBounds.height]}rotateCanvas(t,e,s){const a=t/this.canvasBounds.width,n=e/this.canvasBounds.height,r=this.composeRelPoint(a,n,this.scale,0,0,s),i=this.composeRelPoint(a,n);this.setTranslateFromUserGesture(i[0]-r[0],i[1]-r[1]),this.rotate=s,this.update()}get renderinScale(){return this.naturalScale*this.scale}get renderingTranslateX(){return this.offset.left+this.translateX}get renderingTranslateY(){return this.offset.top+this.translateY}get renderingRotate(){return this.rotate}clampTranslate(t,e=[.5,.5]){const s=this.canvasBounds.width*this.naturalScale*t.scale,a=this.canvasBounds.height*this.naturalScale*t.scale,n=s-this.wrapperInnerWidth,r=a-this.wrapperInnerHeight,i=n>0?-n:0,l=Math.min(0,Math.max(t.translateX,i)),o=r>0?-r:0,c=Math.min(0,Math.max(t.translateY,o)),p=-Math.min(0,n)*e[0],m=-Math.min(0,r)*e[1];return{translateX:l+p,translateY:c+m}}update(){this.canvasElement.style.transformOrigin="top left",this.canvasElement.style.transform=`translateX(${this.renderingTranslateX}px) translateY(${this.renderingTranslateY}px) scale(${this.renderinScale}) rotate(${this.renderingRotate}rad)`,this.dispatchEvent(new Event("update"))}destroy(){}}f.Zoompinch=F,Object.defineProperty(f,Symbol.toStringTag,{value:"Module"})}));
|
package/dist/zoompinch.d.ts
CHANGED
|
@@ -29,6 +29,10 @@ export declare class Zoompinch extends EventTarget {
|
|
|
29
29
|
rotation: boolean;
|
|
30
30
|
wrapperBounds: Bounds;
|
|
31
31
|
canvasBounds: Bounds;
|
|
32
|
+
translateSpeed: number;
|
|
33
|
+
zoomSpeed: number;
|
|
34
|
+
translateSpeedAppleTrackpad: number;
|
|
35
|
+
zoomSpeedAppleTrackpad: number;
|
|
32
36
|
constructor(element: HTMLElement, offset: Offset, translateX: number, translateY: number, scale: number, rotate: number, minScale?: number, maxScale?: number, clampBounds?: boolean, rotation?: boolean);
|
|
33
37
|
get canvasElement(): HTMLElement;
|
|
34
38
|
get wrapperInnerX(): number;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zoompinch/core",
|
|
3
3
|
"description": "Pinch-and-zoom experience that's feels native and communicates the transform reactively and lets you project any layer on top of the transformed canvas",
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.28",
|
|
5
5
|
"private": false,
|
|
6
6
|
"type": "module",
|
|
7
7
|
"main": "./dist/zoompinch-core.umd.js",
|