Esri / feedback-js-api-next

Try out the next release of the ArcGIS Maps SDK for JavaScript and share your feedback. Be warned: this release is still in development and is unstable.
87 stars 23 forks source link

Bug: MapView.goTo does not work as expected #268

Closed tsarapke closed 10 months ago

tsarapke commented 1 year ago

IMPORTANT

Actual behavior

Calling MapView.goTo during existing animation stops previous animation and does not proceed to new location.

We are trying to implement a feature, where user can click on a button and after clicking on a button - it should smoothly move-and-zoom presentation to specific coordinates (array of 4 points).

For that purposes we are using MapView.goTo command in following way:

mapView.goTo([p1, p2, p3, p4], {
    animation: true,
    duration: 5000,
    easing: "ease-out"
});

When user click one button, during 5 seconds it should move presentation to position A. If user will click another button after 2 seconds after previous click - it should start move presentation to position B. But it doesn't. Instead it stoped in the middle on the way to position A.

Moreover, I can see from documentation, that options parameters in MapView.goTo callback supports a signal. But it looks like it does't work.

const abortController = new AbortController();

const goToPromise = mapView.goTo([p1, p2, p3, p4], {
    animation: true,
    duration: 5000,
    easing: "ease-out",
    signal: abortController.signal
});

setTimeout(() => {
    abortController.abort();
}, 2000);

After calling abort, goToPromise does not rejected and animation is successfully finished.

Expected behavior

I would expect, that MapView.goTo command will cancel previous animation and start new animation. For now it seems to be broken and does not work in that way.

Moreover, I would expect that calling abort of abortController should stop animation and reject the promise. But it doesn't.

Reproduction sample

https://codesandbox.io/s/funny-brook-dxdkpt

Reproduction steps

  1. Open the sandbox
  2. Click "Go to Africa". It will start animation for 5s
  3. Click "Go to North America"
  4. Animation is stopped and does not go to location of North America

Reproduction browser

Chrome 119 on macOS (Sonoma)

SDK version (check your console)

ArcGIS Maps SDK for JavaScript 4.29-next [Date: 20231113, Revision: 5c229bdf]

Also checked for all versions starting from 4.23

Operating System (check https://whatsmyos.com)

ubatsukh commented 12 months ago

Hi there,

Thank you for reporting this issue. We are looking into this issue and will update you on esri community - https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/mapview-goto-stops-working-on-second-call-and-does/m-p/1351540#M82830 once we have a fix.

ubatsukh commented 10 months ago

Hi there,

This issue is fixed at version 4.29. You can check the fix using our next version: https://github.com/Esri/feedback-js-api-next/blob/main/CHANGELOG.md.

Please feel free to reach out if you still see issues.