Skip to content

zoomToPoint ignores { animate: true } due to option merging order #692

@ahzvenol

Description

@ahzvenol

Describe the bug

zoomToPoint() does not respect the animate option passed by the caller. Even when explicitly passing { animate: true }, the transition is always disabled.

This appears to be caused by commit ea78bd1, which changed the options merge order in zoomToPoint():

Before (animate could be overridden by caller):

return zoom(toScale, { animate: false, ...zoomOptions, focal }, originalEvent)

After (animate is always false):

return zoom(toScale, { ...zoomOptions, animate: false, focal }, originalEvent)

With the current order, animate: false is placed after ...zoomOptions, so it always overwrites any animate: true passed by the user.

Your environment

  • Version of panzoom: 4.6.1
  • Browser and browser version: any browser

Expected behavior

When calling panzoom.zoomToPoint(2, event, { animate: true }), the zoom should animate smoothly to the target scale.

Actual behavior

The animate: true option is ignored. The element's inline style always shows transition: none, and the zoom happens instantly without animation.

Steps to reproduce

const panzoom = Panzoom(elem)

elem.addEventListener('dblclick', (event) => {
  // This should animate, but it doesn't
  panzoom.zoomToPoint(2, event, { animate: true })
})

Metadata

Metadata

Assignees

No one assigned

    Labels

    behavior changeSignifies a major version update

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions