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

[question]How do I write code to stop/resume autoRotate when mouse click? #49

Closed
moranno opened this issue Jun 19, 2021 · 2 comments
Closed

Comments

@moranno
Copy link

moranno commented Jun 19, 2021

I just find a example here:
vasturiano/react-globe.gl#55 (comment)
But it doesn't work in this version.

1.How do I write code to stop/resume autoRotate when mouse click?
2.Which version should I use? Ract ver or this ver? for performance wise?

Thanks for the great work!

@vasturiano
Copy link
Owner

  1. You can set auto-rotation of the globe via:
myGlobe.controls().autoRotate = false; // or true

So you just need to associate that action to your click event.

Additionally, if you just want to cancel the auto-rotation when the user manually zooms/pans the globe, you can do this:

// assuming auto-rotation has been previously engaged
const controls = myGlobe.controls();
controls.addEventListener('start', () => controls.autoRotate = false);
  1. Performance wise, both versions should be equivalent. You can choose whichever framework is more convenient for your app.

@moranno
Copy link
Author

moranno commented Jun 20, 2021

Thank You!

@moranno moranno closed this as completed Jun 20, 2021
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