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

fix (controls): add an offset after mouse movement #611

Merged
merged 1 commit into from
Jan 15, 2018

Conversation

zarov
Copy link
Contributor

@zarov zarov commented Jan 4, 2018

When moving the globe using GlobeControls, there was some kind of offset, the globe not staying right under the cursor. This is visible if the container of the canvas is not occupying the full page, the container has a CSS position property different of the default static and there are elements right before it on the page, like the geoportal case.

The solution to avoid this, is to detect the position of the container and add an offset according to this position, using the getBoundingClientRect method of the container.

@elias75015 could you test this fix ?

Note: as I tweaked the GlobeControls, I can confirm that we need to resolve issue #545, as there were some other bugs as well.

@zarov zarov added the bug 🐛 label Jan 4, 2018
Copy link
Contributor

@gchoqueux gchoqueux left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, thanks

@@ -904,8 +904,13 @@ function GlobeControls(view, target, radius, options = {}) {

event.preventDefault();

const staticPos = window.getComputedStyle(event.target.parentElement).position !== 'static';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could you factorize this part that appears several times?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nope, it depends on the event, and this variable is available in the function scope only. As GlobeControls is a sort of singleton (correct me if I'm wrong), we can't compute the value at the init of the class.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, you could pass the event as a parameter.
In short, it isn't important.

@gchoqueux
Copy link
Contributor

@elias75015 can you test if the bug is fixed?

When moving the globe using GlobeControls, there was some kind of
offset, the globe not staying right under the cursor. This is visible if
the container of the canvas is not occupying the full page, the
container has a CSS position property different of the default 'static'
and there are elements right before it on the page, like the geoportal
case.

The solution to avoid this, is to detect the position of the container
and add an offset according to this position, using the
getBoundingClientRect method of the container.
@zarov zarov force-pushed the fix-globe-controls-offset branch from cec996c to bf71599 Compare January 11, 2018 09:07
@pjjmunier
Copy link
Contributor

The following bugs have been corrected :

  • inconsistency of the coords picked in 3D with the mouse
  • appearance of an offset between the cursor and the globe by moving the globe with the mouse

@gchoqueux gchoqueux merged commit f3d7772 into master Jan 15, 2018
@gchoqueux gchoqueux deleted the fix-globe-controls-offset branch January 15, 2018 10:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants