jonobr1 / two.js

A renderer agnostic two-dimensional drawing api for the web.
https://two.js.org
MIT License
8.27k stars 454 forks source link

Issues with Zoom and ZUI when upgrading from version 8.1.1 to 8.11 (latest) #711

Closed alfredo-valero closed 10 months ago

alfredo-valero commented 10 months ago

Describe your question As always, first of all, I want to congratulate you on your great work, it's incredible. I'm in the process of updating Two.js in my Angular 13 application (from 8.1.1 to 8.11), but I'm encountering an issue with Zoom (via ZUI) that I had implemented, which was working perfectly before, but now it's giving me an error. The error is very similar to what happens when you try to zoom using the scroll wheel in the sample projects you have (https://codepen.io/jonobr1/pen/PobMKwb).

image

In my applicaction, this is the result of applying the 'zoomby' method (Debugging in the devtools Chrome)

image

After that: image

(Note: "y" is negative because I changed the coordinate origin to the bottom left)

This is how I declare and initialize the objects in version 8.11 (it's almost the same as the one used in 8.1.1):

... import Two from 'two.js'; import { ZUI } from 'two.js/extras/jsm/zui.js'; import { Group } from 'two.js/src/group'; import { Path } from 'two.js/src/path'; import { Points } from 'two.js/src/shapes/points'; import { Vector } from 'two.js/src/vector'; ....

this.map.two = new Two({ type: Two.Types.svg, fitted:true, }).appendTo(this.drawArea.nativeElement); ...

this.map.zui = new ZUI(this.map.stage);
this.map.zui.addLimits( -Infinity, Infinity);

In the map service, I define zui: ZUI; two: Two;

Nothing special!

Just like in the example project's code, panning works for me, but zoom doesn't.

I've gone through it many times, and I can't find the problem. It's starting to become quite frustrating. Any ideas on what might be happening?

Thanks in advance.

alfredo-valero commented 10 months ago

Is it possible that there's an error here?

image image

jonobr1 commented 10 months ago

Thanks for posting. This PR has the fix: https://github.com/jonobr1/two.js/pull/712

Will push a new build of Two.js out now

alfredo-valero commented 10 months ago

Great! Thank you very much.