diff --git a/README.md b/README.md
index 208fc7d9..37b1297b 100644
--- a/README.md
+++ b/README.md
@@ -138,7 +138,7 @@ setTimeout(() => panzoom.pan(100, 100))
▸ **Panzoom**(`elem`: HTMLElement | SVGElement, `options?`: Omit‹[PanzoomOptions](#PanzoomOptions), "force"›): _[PanzoomObject](#PanzoomObject)_
-_Defined in [panzoom.ts:49](https://github.com/timmywil/panzoom/blob/d0b9505/src/panzoom.ts#L49)_
+_Defined in [panzoom.ts:49](https://github.com/timmywil/panzoom/blob/b082b5a/src/panzoom.ts#L49)_
**Parameters:**
@@ -161,7 +161,7 @@ Includes `MiscOptions`, `PanOptions`, and `ZoomOptions`
• **animate**? : _boolean_ (Default: **false**)
-_Defined in [types.ts:13](https://github.com/timmywil/panzoom/blob/d0b9505/src/types.ts#L13)_
+_Defined in [types.ts:13](https://github.com/timmywil/panzoom/blob/b082b5a/src/types.ts#L13)_
Whether to animate transitions
@@ -171,7 +171,7 @@ Whether to animate transitions
• **duration**? : _number_ (Default: **200**)
-_Defined in [types.ts:15](https://github.com/timmywil/panzoom/blob/d0b9505/src/types.ts#L15)_
+_Defined in [types.ts:15](https://github.com/timmywil/panzoom/blob/b082b5a/src/types.ts#L15)_
Duration of the transition (ms)
@@ -181,7 +181,7 @@ Duration of the transition (ms)
• **easing**? : _string_ (Default: **"ease-in-out"**)
-_Defined in [types.ts:17](https://github.com/timmywil/panzoom/blob/d0b9505/src/types.ts#L17)_
+_Defined in [types.ts:17](https://github.com/timmywil/panzoom/blob/b082b5a/src/types.ts#L17)_
CSS Easing used for transitions
@@ -191,7 +191,7 @@ CSS Easing used for transitions
• **exclude**? : _Element[]_
-_Defined in [types.ts:24](https://github.com/timmywil/panzoom/blob/d0b9505/src/types.ts#L24)_
+_Defined in [types.ts:24](https://github.com/timmywil/panzoom/blob/b082b5a/src/types.ts#L24)_
Add elements to this array that should be excluded
from Panzoom handling.
@@ -204,7 +204,7 @@ e.g. links and buttons that should not propagate the click event.
• **excludeClass**? : _string_ (Default: **"panzoom-exclude"**)
-_Defined in [types.ts:31](https://github.com/timmywil/panzoom/blob/d0b9505/src/types.ts#L31)_
+_Defined in [types.ts:31](https://github.com/timmywil/panzoom/blob/b082b5a/src/types.ts#L31)_
Add this class to any element within the Panzoom element
that you want to exclude from Panzoom handling. That
@@ -217,7 +217,7 @@ e.g. links and buttons that should not propagate the click event.
• **force**? : _boolean_
-_Defined in [types.ts:47](https://github.com/timmywil/panzoom/blob/d0b9505/src/types.ts#L47)_
+_Defined in [types.ts:47](https://github.com/timmywil/panzoom/blob/b082b5a/src/types.ts#L47)_
`force` should be used sparingly to temporarily
override and ignore options such as disablePan,
@@ -239,7 +239,7 @@ panzoom.zoom(1, { force: true })
• **handleStartEvent**? : _function_
-_Defined in [types.ts:71](https://github.com/timmywil/panzoom/blob/d0b9505/src/types.ts#L71)_
+_Defined in [types.ts:71](https://github.com/timmywil/panzoom/blob/b082b5a/src/types.ts#L71)_
On the first pointer event, when panning starts,
the default Panzoom behavior is to call
@@ -279,7 +279,7 @@ Panzoom(elem, {
• **origin**? : _string_
-_Defined in [types.ts:85](https://github.com/timmywil/panzoom/blob/d0b9505/src/types.ts#L85)_
+_Defined in [types.ts:85](https://github.com/timmywil/panzoom/blob/b082b5a/src/types.ts#L85)_
**Change this at your own risk.**
The `transform-origin` is the origin from which transforms are applied.
@@ -299,7 +299,7 @@ And again, changing this for SVG in IE doesn't work at all.
• **overflow**? : _string_ (Default: **"hidden"**)
-_Defined in [types.ts:87](https://github.com/timmywil/panzoom/blob/d0b9505/src/types.ts#L87)_
+_Defined in [types.ts:87](https://github.com/timmywil/panzoom/blob/b082b5a/src/types.ts#L87)_
The overflow CSS value for the parent. Defaults to 'hidden'
@@ -309,7 +309,7 @@ The overflow CSS value for the parent. Defaults to 'hidden'
• **setTransform**? : _setTransform_
-_Defined in [types.ts:105](https://github.com/timmywil/panzoom/blob/d0b9505/src/types.ts#L105)_
+_Defined in [types.ts:105](https://github.com/timmywil/panzoom/blob/b082b5a/src/types.ts#L105)_
Override the transform setter.
This is exposed mostly so the user could
@@ -333,7 +333,7 @@ const panzoom = Panzoom(elem, {
• **silent**? : _boolean_
-_Defined in [types.ts:107](https://github.com/timmywil/panzoom/blob/d0b9505/src/types.ts#L107)_
+_Defined in [types.ts:107](https://github.com/timmywil/panzoom/blob/b082b5a/src/types.ts#L107)_
Silence all events
@@ -343,7 +343,7 @@ Silence all events
• **startScale**? : _number_ (Default: **1**)
-_Defined in [types.ts:113](https://github.com/timmywil/panzoom/blob/d0b9505/src/types.ts#L113)_
+_Defined in [types.ts:113](https://github.com/timmywil/panzoom/blob/b082b5a/src/types.ts#L113)_
Scale used to set the beginning transform
@@ -353,7 +353,7 @@ Scale used to set the beginning transform
• **startX**? : _number_ (Default: **0**)
-_Defined in [types.ts:109](https://github.com/timmywil/panzoom/blob/d0b9505/src/types.ts#L109)_
+_Defined in [types.ts:109](https://github.com/timmywil/panzoom/blob/b082b5a/src/types.ts#L109)_
X Value used to set the beginning transform
@@ -363,7 +363,7 @@ X Value used to set the beginning transform
• **startY**? : _number_ (Default: **0**)
-_Defined in [types.ts:111](https://github.com/timmywil/panzoom/blob/d0b9505/src/types.ts#L111)_
+_Defined in [types.ts:111](https://github.com/timmywil/panzoom/blob/b082b5a/src/types.ts#L111)_
Y Value used to set the beginning transform
@@ -377,7 +377,7 @@ Includes `MiscOptions`
• **contain**? : _"inside" | "outside"_
-_Defined in [types.ts:130](https://github.com/timmywil/panzoom/blob/d0b9505/src/types.ts#L130)_
+_Defined in [types.ts:130](https://github.com/timmywil/panzoom/blob/b082b5a/src/types.ts#L130)_
Contain the panzoom element either
inside or outside the parent.
@@ -395,7 +395,7 @@ empty space around the element will be shown.
• **cursor**? : _string_ (Default: **"move"**)
-_Defined in [types.ts:132](https://github.com/timmywil/panzoom/blob/d0b9505/src/types.ts#L132)_
+_Defined in [types.ts:132](https://github.com/timmywil/panzoom/blob/b082b5a/src/types.ts#L132)_
The cursor style to set on the panzoom element
@@ -405,7 +405,7 @@ The cursor style to set on the panzoom element
• **disablePan**? : _boolean_ (Default: **false**)
-_Defined in [types.ts:138](https://github.com/timmywil/panzoom/blob/d0b9505/src/types.ts#L138)_
+_Defined in [types.ts:138](https://github.com/timmywil/panzoom/blob/b082b5a/src/types.ts#L138)_
Disable panning functionality.
Note: disablePan does not affect focal point zooming or the constrain option.
@@ -417,7 +417,7 @@ The element will still pan accordingly.
• **disableXAxis**? : _boolean_ (Default: **false**)
-_Defined in [types.ts:140](https://github.com/timmywil/panzoom/blob/d0b9505/src/types.ts#L140)_
+_Defined in [types.ts:140](https://github.com/timmywil/panzoom/blob/b082b5a/src/types.ts#L140)_
Pan only on the Y axis
@@ -427,7 +427,7 @@ Pan only on the Y axis
• **disableYAxis**? : _boolean_ (Default: **false**)
-_Defined in [types.ts:142](https://github.com/timmywil/panzoom/blob/d0b9505/src/types.ts#L142)_
+_Defined in [types.ts:142](https://github.com/timmywil/panzoom/blob/b082b5a/src/types.ts#L142)_
Pan only on the X axis
@@ -437,7 +437,7 @@ Pan only on the X axis
• **panOnlyWhenZoomed**? : _boolean_ (Default: **false**)
-_Defined in [types.ts:146](https://github.com/timmywil/panzoom/blob/d0b9505/src/types.ts#L146)_
+_Defined in [types.ts:146](https://github.com/timmywil/panzoom/blob/b082b5a/src/types.ts#L146)_
Disable panning while the scale is equal to the starting value
@@ -447,7 +447,7 @@ Disable panning while the scale is equal to the starting value
• **relative**? : _boolean_ (Default: **false**)
-_Defined in [types.ts:144](https://github.com/timmywil/panzoom/blob/d0b9505/src/types.ts#L144)_
+_Defined in [types.ts:144](https://github.com/timmywil/panzoom/blob/b082b5a/src/types.ts#L144)_
When passing x and y values to .pan(), treat the values as relative to their current values
@@ -461,7 +461,7 @@ Includes `MiscOptions`
• **disableZoom**? : _boolean_ (Default: **false**)
-_Defined in [types.ts:151](https://github.com/timmywil/panzoom/blob/d0b9505/src/types.ts#L151)_
+_Defined in [types.ts:151](https://github.com/timmywil/panzoom/blob/b082b5a/src/types.ts#L151)_
Disable zooming functionality
@@ -471,7 +471,7 @@ Disable zooming functionality
• **focal**? : _object_
-_Defined in [types.ts:158](https://github.com/timmywil/panzoom/blob/d0b9505/src/types.ts#L158)_
+_Defined in [types.ts:158](https://github.com/timmywil/panzoom/blob/b082b5a/src/types.ts#L158)_
Zoom to the given point on the panzoom element.
This point is expected to be relative to
@@ -490,7 +490,7 @@ to the parent dimensions.
• **maxScale**? : _number_ (Default: **4**)
-_Defined in [types.ts:162](https://github.com/timmywil/panzoom/blob/d0b9505/src/types.ts#L162)_
+_Defined in [types.ts:162](https://github.com/timmywil/panzoom/blob/b082b5a/src/types.ts#L162)_
The maximum scale when zooming
@@ -500,7 +500,7 @@ The maximum scale when zooming
• **minScale**? : _number_ (Default: **0.125**)
-_Defined in [types.ts:160](https://github.com/timmywil/panzoom/blob/d0b9505/src/types.ts#L160)_
+_Defined in [types.ts:160](https://github.com/timmywil/panzoom/blob/b082b5a/src/types.ts#L160)_
The minimum scale when zooming
@@ -510,7 +510,7 @@ The minimum scale when zooming
• **step**? : _number_ (Default: **0.3**)
-_Defined in [types.ts:164](https://github.com/timmywil/panzoom/blob/d0b9505/src/types.ts#L164)_
+_Defined in [types.ts:164](https://github.com/timmywil/panzoom/blob/b082b5a/src/types.ts#L164)_
The step affects zoom calculation when zooming with a mouse wheel, when pinch zooming, or when using zoomIn/zoomOut
@@ -524,7 +524,7 @@ These methods are available after initializing Panzoom
• **destroy**: _function_
-_Defined in [types.ts:179](https://github.com/timmywil/panzoom/blob/d0b9505/src/types.ts#L179)_
+_Defined in [types.ts:179](https://github.com/timmywil/panzoom/blob/b082b5a/src/types.ts#L179)_
Remove all event listeners bind to the the Panzoom element
@@ -538,7 +538,7 @@ Remove all event listeners bind to the the Panzoom element
• **getOptions**: _function_
-_Defined in [types.ts:185](https://github.com/timmywil/panzoom/blob/d0b9505/src/types.ts#L185)_
+_Defined in [types.ts:185](https://github.com/timmywil/panzoom/blob/b082b5a/src/types.ts#L185)_
Returns a _copy_ of the current options object
@@ -552,7 +552,7 @@ Returns a _copy_ of the current options object
• **getPan**: _function_
-_Defined in [types.ts:181](https://github.com/timmywil/panzoom/blob/d0b9505/src/types.ts#L181)_
+_Defined in [types.ts:181](https://github.com/timmywil/panzoom/blob/b082b5a/src/types.ts#L181)_
Get the current x/y translation
@@ -570,7 +570,7 @@ Get the current x/y translation
• **getScale**: _function_
-_Defined in [types.ts:183](https://github.com/timmywil/panzoom/blob/d0b9505/src/types.ts#L183)_
+_Defined in [types.ts:183](https://github.com/timmywil/panzoom/blob/b082b5a/src/types.ts#L183)_
Get the current scale
@@ -584,7 +584,7 @@ Get the current scale
• **pan**: _function_
-_Defined in [types.ts:196](https://github.com/timmywil/panzoom/blob/d0b9505/src/types.ts#L196)_
+_Defined in [types.ts:196](https://github.com/timmywil/panzoom/blob/b082b5a/src/types.ts#L196)_
Pan the Panzoom element to the given x and y coordinates
@@ -613,7 +613,7 @@ panzoom.pan(10, 10, { relative: true })
• **reset**: _function_
-_Defined in [types.ts:207](https://github.com/timmywil/panzoom/blob/d0b9505/src/types.ts#L207)_
+_Defined in [types.ts:207](https://github.com/timmywil/panzoom/blob/b082b5a/src/types.ts#L207)_
Reset the pan and zoom to startX, startY, and startScale.
Animates by default, ignoring the global option.
@@ -640,7 +640,7 @@ panzoom.reset({ animate: false })
• **setOptions**: _function_
-_Defined in [types.ts:209](https://github.com/timmywil/panzoom/blob/d0b9505/src/types.ts#L209)_
+_Defined in [types.ts:209](https://github.com/timmywil/panzoom/blob/b082b5a/src/types.ts#L209)_
Change options for the Panzoom instance
@@ -660,7 +660,7 @@ Change options for the Panzoom instance
• **setStyle**: _function_
-_Defined in [types.ts:211](https://github.com/timmywil/panzoom/blob/d0b9505/src/types.ts#L211)_
+_Defined in [types.ts:211](https://github.com/timmywil/panzoom/blob/b082b5a/src/types.ts#L211)_
A convenience method for setting prefixed styles on the Panzoom element
@@ -681,7 +681,7 @@ A convenience method for setting prefixed styles on the Panzoom element
• **zoom**: _function_
-_Defined in [types.ts:220](https://github.com/timmywil/panzoom/blob/d0b9505/src/types.ts#L220)_
+_Defined in [types.ts:220](https://github.com/timmywil/panzoom/blob/b082b5a/src/types.ts#L220)_
Zoom the Panzoom element to the given scale
@@ -707,7 +707,7 @@ panzoom.zoom(2.2, { animate: true })
• **zoomIn**: _function_
-_Defined in [types.ts:231](https://github.com/timmywil/panzoom/blob/d0b9505/src/types.ts#L231)_
+_Defined in [types.ts:231](https://github.com/timmywil/panzoom/blob/b082b5a/src/types.ts#L231)_
Zoom in using the predetermined increment set in options.
Animates by default, ignoring the global option.
@@ -734,7 +734,7 @@ panzoom.zoomIn({ animate: false })
• **zoomOut**: _function_
-_Defined in [types.ts:242](https://github.com/timmywil/panzoom/blob/d0b9505/src/types.ts#L242)_
+_Defined in [types.ts:242](https://github.com/timmywil/panzoom/blob/b082b5a/src/types.ts#L242)_
Zoom out using the predetermined increment set in options.
Animates by default, ignoring the global option.
@@ -761,7 +761,7 @@ panzoom.zoomOut({ animate: false })
• **zoomToPoint**: _function_
-_Defined in [types.ts:253](https://github.com/timmywil/panzoom/blob/d0b9505/src/types.ts#L253)_
+_Defined in [types.ts:253](https://github.com/timmywil/panzoom/blob/b082b5a/src/types.ts#L253)_
Zoom the Panzoom element to a focal point using
the given pointer/touch/mouse event or constructed point.
@@ -795,7 +795,7 @@ panzoom.zoomToPoint(1.2, pointerEvent)
• **zoomWithWheel**: _function_
-_Defined in [types.ts:282](https://github.com/timmywil/panzoom/blob/d0b9505/src/types.ts#L282)_
+_Defined in [types.ts:282](https://github.com/timmywil/panzoom/blob/b082b5a/src/types.ts#L282)_
Zoom the Panzoom element to a focal point using the given WheelEvent
@@ -839,7 +839,7 @@ elem.parentElement.addEventListener('wheel', function(event) {
• **scale**: _number_
-_Defined in [types.ts:174](https://github.com/timmywil/panzoom/blob/d0b9505/src/types.ts#L174)_
+_Defined in [types.ts:174](https://github.com/timmywil/panzoom/blob/b082b5a/src/types.ts#L174)_
---
@@ -847,7 +847,7 @@ _Defined in [types.ts:174](https://github.com/timmywil/panzoom/blob/d0b9505/src/
• **x**: _number_
-_Defined in [types.ts:172](https://github.com/timmywil/panzoom/blob/d0b9505/src/types.ts#L172)_
+_Defined in [types.ts:172](https://github.com/timmywil/panzoom/blob/b082b5a/src/types.ts#L172)_
---
@@ -855,7 +855,7 @@ _Defined in [types.ts:172](https://github.com/timmywil/panzoom/blob/d0b9505/src/
• **y**: _number_
-_Defined in [types.ts:173](https://github.com/timmywil/panzoom/blob/d0b9505/src/types.ts#L173)_
+_Defined in [types.ts:173](https://github.com/timmywil/panzoom/blob/b082b5a/src/types.ts#L173)_
## Events
diff --git a/dist/demo/Code.d.ts b/dist/demo/Code.d.ts
new file mode 100644
index 00000000..eea2bf30
--- /dev/null
+++ b/dist/demo/Code.d.ts
@@ -0,0 +1,8 @@
+///
+import 'prismjs/themes/prism-tomorrow.css';
+interface Props {
+ language?: string;
+ children: string;
+}
+export default function Code({ children, language }: Props): JSX.Element;
+export {};
diff --git a/dist/demo/Demo.d.ts b/dist/demo/Demo.d.ts
new file mode 100644
index 00000000..0be06018
--- /dev/null
+++ b/dist/demo/Demo.d.ts
@@ -0,0 +1,8 @@
+import React from 'react';
+interface Props {
+ title: string;
+ code: React.ReactNode;
+ children: React.ReactNode;
+}
+export default function Demo({ title, code, children }: Props): JSX.Element;
+export {};
diff --git a/dist/demo/examples/ContainInside.d.ts b/dist/demo/examples/ContainInside.d.ts
new file mode 100644
index 00000000..c2df5d65
--- /dev/null
+++ b/dist/demo/examples/ContainInside.d.ts
@@ -0,0 +1,2 @@
+///
+export default function ContainInside(): JSX.Element;
diff --git a/dist/demo/examples/ContainOutside.d.ts b/dist/demo/examples/ContainOutside.d.ts
new file mode 100644
index 00000000..134ff4e8
--- /dev/null
+++ b/dist/demo/examples/ContainOutside.d.ts
@@ -0,0 +1,2 @@
+///
+export default function ContainOutside(): JSX.Element;
diff --git a/dist/demo/examples/DisabledYAxis.d.ts b/dist/demo/examples/DisabledYAxis.d.ts
new file mode 100644
index 00000000..c2df5d65
--- /dev/null
+++ b/dist/demo/examples/DisabledYAxis.d.ts
@@ -0,0 +1,2 @@
+///
+export default function ContainInside(): JSX.Element;
diff --git a/dist/demo/examples/Exclude.d.ts b/dist/demo/examples/Exclude.d.ts
new file mode 100644
index 00000000..db570b76
--- /dev/null
+++ b/dist/demo/examples/Exclude.d.ts
@@ -0,0 +1,2 @@
+///
+export default function Exclude(): JSX.Element;
diff --git a/dist/demo/examples/Focal.d.ts b/dist/demo/examples/Focal.d.ts
new file mode 100644
index 00000000..f267e4dc
--- /dev/null
+++ b/dist/demo/examples/Focal.d.ts
@@ -0,0 +1,2 @@
+///
+export default function Focal(): JSX.Element;
diff --git a/dist/demo/examples/SVG.d.ts b/dist/demo/examples/SVG.d.ts
new file mode 100644
index 00000000..45587b1d
--- /dev/null
+++ b/dist/demo/examples/SVG.d.ts
@@ -0,0 +1,2 @@
+///
+export default function SVG(): JSX.Element;
diff --git a/dist/demo/examples/Standard.d.ts b/dist/demo/examples/Standard.d.ts
new file mode 100644
index 00000000..d264f89e
--- /dev/null
+++ b/dist/demo/examples/Standard.d.ts
@@ -0,0 +1,2 @@
+///
+export default function Buttons(): JSX.Element;
diff --git a/dist/demo/global-panzoom.d.ts b/dist/demo/global-panzoom.d.ts
new file mode 100644
index 00000000..cf448d39
--- /dev/null
+++ b/dist/demo/global-panzoom.d.ts
@@ -0,0 +1,6 @@
+import Panzoom from '../src/panzoom';
+declare global {
+ interface Window {
+ Panzoom: typeof Panzoom;
+ }
+}
diff --git a/dist/demo/index.d.ts b/dist/demo/index.d.ts
new file mode 100644
index 00000000..1b443e33
--- /dev/null
+++ b/dist/demo/index.d.ts
@@ -0,0 +1,2 @@
+import './demo.css';
+import './global-panzoom';
diff --git a/dist/panzoom.js b/dist/panzoom.js
new file mode 100644
index 00000000..532e8b52
--- /dev/null
+++ b/dist/panzoom.js
@@ -0,0 +1,691 @@
+/**
+ * Panzoom for panning and zooming elements using CSS transforms
+ * Copyright Timmy Willison and other contributors
+ * https://github.com/timmywil/panzoom/blob/master/MIT-License.txt
+ */
+(function (global, factory) {
+ typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
+ typeof define === 'function' && define.amd ? define(factory) :
+ (global = global || self, global.Panzoom = factory());
+}(this, (function () { 'use strict';
+
+ /*! *****************************************************************************
+ Copyright (c) Microsoft Corporation. All rights reserved.
+ Licensed under the Apache License, Version 2.0 (the "License"); you may not use
+ this file except in compliance with the License. You may obtain a copy of the
+ License at http://www.apache.org/licenses/LICENSE-2.0
+
+ THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
+ WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
+ MERCHANTABLITY OR NON-INFRINGEMENT.
+
+ See the Apache Version 2.0 License for specific language governing permissions
+ and limitations under the License.
+ ***************************************************************************** */
+
+ var __assign = function() {
+ __assign = Object.assign || function __assign(t) {
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
+ s = arguments[i];
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
+ }
+ return t;
+ };
+ return __assign.apply(this, arguments);
+ };
+
+ /* eslint-disable no-var */
+ // Support: IE11 only
+ if (window.NodeList && !NodeList.prototype.forEach) {
+ NodeList.prototype.forEach = Array.prototype.forEach;
+ }
+ // Support: IE11 only
+ // CustomEvent is an object instead of a constructor
+ if (typeof window.CustomEvent !== 'function') {
+ window.CustomEvent = function CustomEvent(event, params) {
+ params = params || { bubbles: false, cancelable: false, detail: null };
+ var evt = document.createEvent('CustomEvent');
+ evt.initCustomEvent(event, params.bubbles, params.cancelable, params.detail);
+ return evt
+ };
+ }
+
+ /**
+ * Utilites for working with multiple pointer events
+ */
+ function findEventIndex(pointers, event) {
+ var i = pointers.length;
+ while (i--) {
+ if (pointers[i].pointerId === event.pointerId) {
+ return i;
+ }
+ }
+ return -1;
+ }
+ function addPointer(pointers, event) {
+ var i;
+ // Add touches if applicable
+ if (event.touches) {
+ i = 0;
+ for (var _i = 0, _a = event.touches; _i < _a.length; _i++) {
+ var touch = _a[_i];
+ touch.pointerId = i++;
+ addPointer(pointers, touch);
+ }
+ return;
+ }
+ i = findEventIndex(pointers, event);
+ // Update if already present
+ if (i > -1) {
+ pointers.splice(i, 1);
+ }
+ pointers.push(event);
+ }
+ function removePointer(pointers, event) {
+ // Add touches if applicable
+ if (event.touches) {
+ // Remove all touches
+ while (pointers.length) {
+ pointers.pop();
+ }
+ return;
+ }
+ var i = findEventIndex(pointers, event);
+ if (i > -1) {
+ pointers.splice(i, 1);
+ }
+ }
+ /**
+ * Calculates a center point between
+ * the given pointer events, for panning
+ * with multiple pointers.
+ */
+ function getMiddle(pointers) {
+ // Copy to avoid changing by reference
+ pointers = pointers.slice(0);
+ var event1 = pointers.pop();
+ var event2;
+ while ((event2 = pointers.pop())) {
+ event1 = {
+ clientX: (event2.clientX - event1.clientX) / 2 + event1.clientX,
+ clientY: (event2.clientY - event1.clientY) / 2 + event1.clientY
+ };
+ }
+ return event1;
+ }
+ /**
+ * Calculates the distance between two points
+ * for pinch zooming.
+ * Limits to the first 2
+ */
+ function getDistance(pointers) {
+ if (pointers.length < 2) {
+ return 0;
+ }
+ var event1 = pointers[0];
+ var event2 = pointers[1];
+ return Math.sqrt(Math.pow(Math.abs(event2.clientX - event1.clientX), 2) +
+ Math.pow(Math.abs(event2.clientY - event1.clientY), 2));
+ }
+
+ var events;
+ if (typeof window.PointerEvent === 'function') {
+ events = {
+ down: 'pointerdown',
+ move: 'pointermove',
+ up: 'pointerup pointerleave pointercancel'
+ };
+ }
+ else if (typeof window.TouchEvent === 'function') {
+ events = {
+ down: 'touchstart',
+ move: 'touchmove',
+ up: 'touchend touchcancel'
+ };
+ }
+ else {
+ events = {
+ down: 'mousedown',
+ move: 'mousemove',
+ up: 'mouseup mouseleave'
+ };
+ }
+ function onPointer(event, elem, handler, eventOpts) {
+ events[event].split(' ').forEach(function (name) {
+ elem.addEventListener(name, handler, eventOpts);
+ });
+ }
+ function destroyPointer(event, elem, handler) {
+ events[event].split(' ').forEach(function (name) {
+ elem.removeEventListener(name, handler);
+ });
+ }
+
+ /**
+ * Proper prefixing for cross-browser compatibility
+ */
+ var divStyle = document.createElement('div').style;
+ var prefixes = ['webkit', 'moz', 'ms'];
+ var prefixCache = {};
+ function getPrefixedName(name) {
+ if (prefixCache[name]) {
+ return prefixCache[name];
+ }
+ if (name in divStyle) {
+ return (prefixCache[name] = name);
+ }
+ var capName = name[0].toUpperCase() + name.slice(1);
+ var i = prefixes.length;
+ while (i--) {
+ var prefixedName = "" + prefixes[i] + capName;
+ if (prefixedName in divStyle) {
+ return (prefixCache[name] = prefixedName);
+ }
+ }
+ }
+ /**
+ * Gets a style value expected to be a number
+ */
+ function getCSSNum(name, style) {
+ return parseFloat(style[getPrefixedName(name)]) || 0;
+ }
+ function getBoxStyle(elem, name, style) {
+ if (style === void 0) { style = window.getComputedStyle(elem); }
+ // Support: FF 68+
+ // Firefox requires specificity for border
+ var suffix = name === 'border' ? 'Width' : '';
+ return {
+ left: getCSSNum(name + "Left" + suffix, style),
+ right: getCSSNum(name + "Right" + suffix, style),
+ top: getCSSNum(name + "Top" + suffix, style),
+ bottom: getCSSNum(name + "Bottom" + suffix, style)
+ };
+ }
+ /**
+ * Set a style using the properly prefixed name
+ */
+ function setStyle(elem, name, value) {
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
+ elem.style[getPrefixedName(name)] = value;
+ }
+ /**
+ * Constructs the transition from panzoom options
+ * and takes care of prefixing the transition and transform
+ */
+ function setTransition(elem, options) {
+ var transition = getPrefixedName('transition');
+ var transform = getPrefixedName('transform');
+ setStyle(elem, transition, transform + " " + options.duration + "ms " + options.easing);
+ }
+ /**
+ * Set the transform using the proper prefix
+ */
+ function setTransform(elem, _a, options) {
+ var x = _a.x, y = _a.y, scale = _a.scale;
+ if (options === void 0) { options = {}; }
+ if (typeof options.animate === 'boolean') {
+ if (options.animate) {
+ setTransition(elem, options);
+ }
+ else {
+ setStyle(elem, 'transition', 'none');
+ }
+ }
+ requestAnimationFrame(function () {
+ setStyle(elem, 'transform', "scale(" + scale + ") translate(" + x + "px, " + y + "px)");
+ });
+ }
+ /**
+ * Dimensions used in containment and focal point zooming
+ */
+ function getDimensions(elem) {
+ var parent = elem.parentElement;
+ var style = window.getComputedStyle(elem);
+ var parentStyle = window.getComputedStyle(parent);
+ var rectElem = elem.getBoundingClientRect();
+ var rectParent = parent.getBoundingClientRect();
+ return {
+ elem: {
+ style: style,
+ width: rectElem.width,
+ height: rectElem.height,
+ top: rectElem.top,
+ bottom: rectElem.bottom,
+ left: rectElem.left,
+ right: rectElem.right,
+ margin: getBoxStyle(elem, 'margin', style),
+ border: getBoxStyle(elem, 'border', style)
+ },
+ parent: {
+ style: parentStyle,
+ width: rectParent.width,
+ height: rectParent.height,
+ top: rectParent.top,
+ bottom: rectParent.bottom,
+ left: rectParent.left,
+ right: rectParent.right,
+ padding: getBoxStyle(parent, 'padding', parentStyle),
+ border: getBoxStyle(parent, 'border', parentStyle)
+ }
+ };
+ }
+
+ /**
+ * Determine if an element is attached to the DOM
+ * Panzoom requires this so events work properly
+ */
+ function isAttached(elem) {
+ var doc = elem.ownerDocument;
+ var parent = elem.parentElement;
+ return doc && parent && doc.nodeType === 9 && parent.nodeType === 1 && doc.contains(parent);
+ }
+
+ function isExcluded(elem, options) {
+ for (var cur = elem; cur != null; cur = cur.parentElement) {
+ if (cur.classList.contains(options.excludeClass) || options.exclude.indexOf(cur) > -1) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ /**
+ * Determine if an element is SVG by checking the namespace
+ * Exception: the