Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 5 additions & 6 deletions src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -384,8 +384,8 @@ const PrismaZoom = forwardRef<Ref, Props>((props, forwardedRef) => {
* @param {MouseEvent} event Mouse event
*/
const handleMouseWheel = (event: WheelEvent) => {
event.preventDefault()
if (!allowZoom || !allowWheel) return
event.preventDefault()

// Use the scroll event delta to determine the zoom velocity
const velocity = (-event.deltaY * scrollVelocity) / 100
Expand All @@ -408,8 +408,8 @@ const PrismaZoom = forwardRef<Ref, Props>((props, forwardedRef) => {
* @param {MouseEvent} event Mouse event
*/
const handleMouseStart = (event: MouseEvent) => {
event.preventDefault()
if (!allowPan || ignoredMouseButtons.includes(event.button)) return
event.preventDefault()

if (lastRequestAnimationIdRef.current) cancelAnimationFrame(lastRequestAnimationIdRef.current)
lastCursorRef.current = [event.pageX, event.pageY]
Expand All @@ -420,9 +420,8 @@ const PrismaZoom = forwardRef<Ref, Props>((props, forwardedRef) => {
* @param {MouseEvent} event Mouse event
*/
const handleMouseMove = (event: MouseEvent) => {
event.preventDefault()

if (!allowPan || !lastCursorRef.current) return
event.preventDefault()

const [posX, posY] = [event.pageX, event.pageY]
const shiftX = posX - lastCursorRef.current[0]
Expand Down Expand Up @@ -596,19 +595,19 @@ const PrismaZoom = forwardRef<Ref, Props>((props, forwardedRef) => {
refCurrentValue?.removeEventListener('touchcancel', handleTouchStop)
}
}
}, [])
}, [allowWheel, allowZoom, allowPan])

const attr = {
...divProps,
ref,
onDoubleClick: handleDoubleClick,
style: {
...divProps.style,
cursor: cursor,
willChange: 'transform',
transition: `transform ease-out ${transitionRef.current}s`,
touchAction: allowParentPanning && zoomRef.current === 1 ? 'pan-x pan-y' : 'none',
transform: `translate3d(${posRef.current[0]}px, ${posRef.current[1]}px, 0) scale(${zoomRef.current})`,
...divProps.style,
},
}

Expand Down