Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Intermittent Update Behavior for Rotation Handle Position in OL-ext in Transform #1037

Closed
Iut57I opened this issue Mar 10, 2024 · 5 comments
Closed

Comments

@Iut57I
Copy link

Iut57I commented Mar 10, 2024

Hello!

I'm currently developing an application using OpenLayers ext and have encountered an issue with updating the position of rotation handles for a Transform interaction, particularly when zooming in or out (i.e., on change:resolution). While I've implemented logic to update the rotation handle's position based on the map's resolution, the updates appear intermittently, with noticeable "jumps" rather than smooth transitions.

Here's an overview of the implementation:

// Code snippet to update rotation handle for a single feature
const updateRotateForSingleObject = (features) => {
  const rotateHandleStyle = new Style({
    // Style definition...
    geometry: () => {
      // Logic to calculate new position based on resolution
    },
  });
  console.log('rotate');
  transformInteraction.setStyle('rotate', rotateHandleStyle);
};

// Listening to resolution changes to update handle position
view.on('change:resolution', function(e) {
  const selectedFeatures = transformInteraction.getFeatures();
  if (selectedFeatures.getLength() > 0) {
    if (selectedFeatures.getLength() > 1) {
      updateRotateForManyObjects(selectedFeatures);
    } else {
      updateRotateForSingleObject(selectedFeatures);
    }
  }
});

Although the console.log('rotate') statement executes every time the resolution changes, indicating the function is indeed being called, the actual position update of the rotation handle does not always reflect immediately in the UI. It seems to update in "jumps" or sometimes requires additional interaction to display correctly.

I'm looking for guidance on the following:

Why might the rotation handle position updates not display smoothly or consistently upon resolution changes?
Are there any recommended practices or adjustments I can make to ensure the position updates more reliably and smoothly?
Any insights or suggestions on how to address this issue would be greatly appreciated. Thank you for your support
AnimationGit

@Viglino
Copy link
Owner

Viglino commented Mar 11, 2024

Maybe it's due to optimization while animating the overlay.
Try to set updateWhileAnimating in the overlay that contains the handles:

transform.overlayLayer_.updateWhileAnimating_ = true;
// and maybe
transform.overlayLayer_.updateWhileInteracting_ = true;

Tell me if it runs, I'll add it on the overlay in constructor.

@Iut57I
Copy link
Author

Iut57I commented Mar 11, 2024

Yes, it worked. I added both :

transform.overlayLayer_.updateWhileAnimating_ = true;
transform.overlayLayer_.updateWhileInteracting_ = true;

Thank you very much. Hope for an update.

@Viglino
Copy link
Owner

Viglino commented Mar 11, 2024

Great, I'll add it in the constructor to have it work out of the box.

@Iut57I
Copy link
Author

Iut57I commented Mar 19, 2024

Hi!
Could you kindly inform me about any upcoming news or updates that we can look forward to?

@Viglino
Copy link
Owner

Viglino commented Mar 21, 2024

My bad! I miss it! 😞
I just pushed a fix.

@Viglino Viglino closed this as completed Apr 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants