react-prismazoom
Advanced tools
Comparing version 3.3.0 to 3.3.1
# Changelog | ||
## [3.3.1] - 2023-03-02 | ||
- Build fix | ||
## [3.3.0] - 2023-03-01 | ||
@@ -4,0 +7,0 @@ - Added optional ignoredMouseButtons prop (thanks apomelitos) |
@@ -22,3 +22,5 @@ import React from 'react'; | ||
allowParentPanning?: boolean | undefined; | ||
allowWheel?: boolean | undefined; | ||
ignoredMouseButtons?: number[] | undefined; | ||
} & React.RefAttributes<Ref>>; | ||
export default PrismaZoom; |
@@ -31,7 +31,6 @@ "use strict"; | ||
var defaultCursor = 'auto'; | ||
var hasMouseDevice = window.matchMedia('(pointer: fine)').matches; | ||
var PrismaZoom = (0, react_1.forwardRef)(function (props, forwardedRef) { | ||
var children = props.children, onPanChange = props.onPanChange, onZoomChange = props.onZoomChange, _a = props.minZoom, minZoom = _a === void 0 ? 1 : _a, _b = props.initialZoom, initialZoom = _b === void 0 ? 1 : _b, _c = props.maxZoom, maxZoom = _c === void 0 ? 5 : _c, _d = props.scrollVelocity, scrollVelocity = _d === void 0 ? 0.2 : _d, _e = props.animDuration, animDuration = _e === void 0 ? 0.25 : _e, _f = props.doubleTouchMaxDelay, doubleTouchMaxDelay = _f === void 0 ? 300 : _f, _g = props.decelerationDuration, decelerationDuration = _g === void 0 ? 750 : _g, _h = props.allowZoom, allowZoom = _h === void 0 ? true : _h, _j = props.allowPan, allowPan = _j === void 0 ? true : _j, _k = props.allowTouchEvents, allowTouchEvents = _k === void 0 ? false : _k, _l = props.allowParentPanning, allowParentPanning = _l === void 0 ? false : _l, divProps = __rest(props | ||
var children = props.children, onPanChange = props.onPanChange, onZoomChange = props.onZoomChange, _a = props.minZoom, minZoom = _a === void 0 ? 1 : _a, _b = props.initialZoom, initialZoom = _b === void 0 ? 1 : _b, _c = props.maxZoom, maxZoom = _c === void 0 ? 5 : _c, _d = props.scrollVelocity, scrollVelocity = _d === void 0 ? 0.2 : _d, _e = props.animDuration, animDuration = _e === void 0 ? 0.25 : _e, _f = props.doubleTouchMaxDelay, doubleTouchMaxDelay = _f === void 0 ? 300 : _f, _g = props.decelerationDuration, decelerationDuration = _g === void 0 ? 750 : _g, _h = props.allowZoom, allowZoom = _h === void 0 ? true : _h, _j = props.allowPan, allowPan = _j === void 0 ? true : _j, _k = props.allowTouchEvents, allowTouchEvents = _k === void 0 ? false : _k, _l = props.allowParentPanning, allowParentPanning = _l === void 0 ? false : _l, _m = props.allowWheel, allowWheel = _m === void 0 ? true : _m, _o = props.ignoredMouseButtons, ignoredMouseButtons = _o === void 0 ? [] : _o, divProps = __rest(props | ||
// Reference to the main element | ||
, ["children", "onPanChange", "onZoomChange", "minZoom", "initialZoom", "maxZoom", "scrollVelocity", "animDuration", "doubleTouchMaxDelay", "decelerationDuration", "allowZoom", "allowPan", "allowTouchEvents", "allowParentPanning"]); | ||
, ["children", "onPanChange", "onZoomChange", "minZoom", "initialZoom", "maxZoom", "scrollVelocity", "animDuration", "doubleTouchMaxDelay", "decelerationDuration", "allowZoom", "allowPan", "allowTouchEvents", "allowParentPanning", "allowWheel", "ignoredMouseButtons"]); | ||
// Reference to the main element | ||
@@ -59,3 +58,3 @@ var ref = (0, react_1.useRef)(null); | ||
var transitionRef = (0, react_1.useRef)(animDuration); | ||
var _m = (0, react_1.useState)(defaultCursor), cursor = _m[0], setCursor = _m[1]; | ||
var _p = (0, react_1.useState)(defaultCursor), cursor = _p[0], setCursor = _p[1]; | ||
var update = function () { | ||
@@ -195,4 +194,4 @@ if (!ref.current) | ||
var zoom = maxZoom; | ||
setPos(getNewPosition(x, y, zoom)); | ||
setZoom(zoom); | ||
setPos(getNewPosition(x, y, zoom)); | ||
setTransitionDuration(animDuration); | ||
@@ -361,3 +360,3 @@ }; | ||
event.preventDefault(); | ||
if (!allowZoom) | ||
if (!allowZoom || !allowWheel) | ||
return; | ||
@@ -382,3 +381,3 @@ // Use the scroll event delta to determine the zoom velocity | ||
event.preventDefault(); | ||
if (!allowPan) | ||
if (!allowPan || ignoredMouseButtons.includes(event.button)) | ||
return; | ||
@@ -512,2 +511,3 @@ if (lastRequestAnimationIdRef.current) | ||
var refCurrentValue = ref.current; | ||
var hasMouseDevice = window.matchMedia('(pointer: fine)').matches; | ||
refCurrentValue === null || refCurrentValue === void 0 ? void 0 : refCurrentValue.addEventListener('wheel', handleMouseWheel, { passive: false }); | ||
@@ -514,0 +514,0 @@ if (hasMouseDevice) { |
@@ -63,4 +63,13 @@ /// <reference types="react" /> | ||
allowParentPanning?: boolean; | ||
/** | ||
* Enable or disable mouse wheel and touchpad zooming in place | ||
*/ | ||
allowWheel?: boolean; | ||
/** | ||
* Optional array of ignored mouse buttons allows to prevent panning for specific mouse buttons. By default all mouse buttons are enabled | ||
* https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/button#value | ||
*/ | ||
ignoredMouseButtons?: number[]; | ||
}; | ||
export type PositionType = [number, number]; | ||
export type CursorType = React.CSSProperties['cursor']; |
@@ -22,3 +22,5 @@ import React from 'react'; | ||
allowParentPanning?: boolean | undefined; | ||
allowWheel?: boolean | undefined; | ||
ignoredMouseButtons?: number[] | undefined; | ||
} & React.RefAttributes<Ref>>; | ||
export default PrismaZoom; |
@@ -29,7 +29,6 @@ var __assign = (this && this.__assign) || function () { | ||
var defaultCursor = 'auto'; | ||
var hasMouseDevice = window.matchMedia('(pointer: fine)').matches; | ||
var PrismaZoom = forwardRef(function (props, forwardedRef) { | ||
var children = props.children, onPanChange = props.onPanChange, onZoomChange = props.onZoomChange, _a = props.minZoom, minZoom = _a === void 0 ? 1 : _a, _b = props.initialZoom, initialZoom = _b === void 0 ? 1 : _b, _c = props.maxZoom, maxZoom = _c === void 0 ? 5 : _c, _d = props.scrollVelocity, scrollVelocity = _d === void 0 ? 0.2 : _d, _e = props.animDuration, animDuration = _e === void 0 ? 0.25 : _e, _f = props.doubleTouchMaxDelay, doubleTouchMaxDelay = _f === void 0 ? 300 : _f, _g = props.decelerationDuration, decelerationDuration = _g === void 0 ? 750 : _g, _h = props.allowZoom, allowZoom = _h === void 0 ? true : _h, _j = props.allowPan, allowPan = _j === void 0 ? true : _j, _k = props.allowTouchEvents, allowTouchEvents = _k === void 0 ? false : _k, _l = props.allowParentPanning, allowParentPanning = _l === void 0 ? false : _l, divProps = __rest(props | ||
var children = props.children, onPanChange = props.onPanChange, onZoomChange = props.onZoomChange, _a = props.minZoom, minZoom = _a === void 0 ? 1 : _a, _b = props.initialZoom, initialZoom = _b === void 0 ? 1 : _b, _c = props.maxZoom, maxZoom = _c === void 0 ? 5 : _c, _d = props.scrollVelocity, scrollVelocity = _d === void 0 ? 0.2 : _d, _e = props.animDuration, animDuration = _e === void 0 ? 0.25 : _e, _f = props.doubleTouchMaxDelay, doubleTouchMaxDelay = _f === void 0 ? 300 : _f, _g = props.decelerationDuration, decelerationDuration = _g === void 0 ? 750 : _g, _h = props.allowZoom, allowZoom = _h === void 0 ? true : _h, _j = props.allowPan, allowPan = _j === void 0 ? true : _j, _k = props.allowTouchEvents, allowTouchEvents = _k === void 0 ? false : _k, _l = props.allowParentPanning, allowParentPanning = _l === void 0 ? false : _l, _m = props.allowWheel, allowWheel = _m === void 0 ? true : _m, _o = props.ignoredMouseButtons, ignoredMouseButtons = _o === void 0 ? [] : _o, divProps = __rest(props | ||
// Reference to the main element | ||
, ["children", "onPanChange", "onZoomChange", "minZoom", "initialZoom", "maxZoom", "scrollVelocity", "animDuration", "doubleTouchMaxDelay", "decelerationDuration", "allowZoom", "allowPan", "allowTouchEvents", "allowParentPanning"]); | ||
, ["children", "onPanChange", "onZoomChange", "minZoom", "initialZoom", "maxZoom", "scrollVelocity", "animDuration", "doubleTouchMaxDelay", "decelerationDuration", "allowZoom", "allowPan", "allowTouchEvents", "allowParentPanning", "allowWheel", "ignoredMouseButtons"]); | ||
// Reference to the main element | ||
@@ -57,3 +56,3 @@ var ref = useRef(null); | ||
var transitionRef = useRef(animDuration); | ||
var _m = useState(defaultCursor), cursor = _m[0], setCursor = _m[1]; | ||
var _p = useState(defaultCursor), cursor = _p[0], setCursor = _p[1]; | ||
var update = function () { | ||
@@ -193,4 +192,4 @@ if (!ref.current) | ||
var zoom = maxZoom; | ||
setPos(getNewPosition(x, y, zoom)); | ||
setZoom(zoom); | ||
setPos(getNewPosition(x, y, zoom)); | ||
setTransitionDuration(animDuration); | ||
@@ -359,3 +358,3 @@ }; | ||
event.preventDefault(); | ||
if (!allowZoom) | ||
if (!allowZoom || !allowWheel) | ||
return; | ||
@@ -380,3 +379,3 @@ // Use the scroll event delta to determine the zoom velocity | ||
event.preventDefault(); | ||
if (!allowPan) | ||
if (!allowPan || ignoredMouseButtons.includes(event.button)) | ||
return; | ||
@@ -510,2 +509,3 @@ if (lastRequestAnimationIdRef.current) | ||
var refCurrentValue = ref.current; | ||
var hasMouseDevice = window.matchMedia('(pointer: fine)').matches; | ||
refCurrentValue === null || refCurrentValue === void 0 ? void 0 : refCurrentValue.addEventListener('wheel', handleMouseWheel, { passive: false }); | ||
@@ -512,0 +512,0 @@ if (hasMouseDevice) { |
@@ -63,4 +63,13 @@ /// <reference types="react" /> | ||
allowParentPanning?: boolean; | ||
/** | ||
* Enable or disable mouse wheel and touchpad zooming in place | ||
*/ | ||
allowWheel?: boolean; | ||
/** | ||
* Optional array of ignored mouse buttons allows to prevent panning for specific mouse buttons. By default all mouse buttons are enabled | ||
* https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/button#value | ||
*/ | ||
ignoredMouseButtons?: number[]; | ||
}; | ||
export type PositionType = [number, number]; | ||
export type CursorType = React.CSSProperties['cursor']; |
{ | ||
"name": "react-prismazoom", | ||
"version": "3.3.0", | ||
"version": "3.3.1", | ||
"description": "A pan and zoom component for React, using CSS transformations.", | ||
@@ -5,0 +5,0 @@ "author": "Sylvain Dubus <svn.dbs@gmail.com>", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
70000
12
1289