Skip to content

Conversation

@jahow
Copy link
Contributor

@jahow jahow commented Apr 5, 2019

Previously, an interaction could begin while target values (center/resolution) were out of the allowed range, causing a glitch where the view zoom/position would jump suddenly.

@ahocevar I've reused your test from #9399 & expanded on it.

Fixes #9396.

Copy link
Member

@ahocevar ahocevar left a comment

Choose a reason for hiding this comment

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

Thanks @jahow. This looks good. Would be great if you could comment on the two questions I added. The reason why I'm asking is because it strikes me as a flaw that interactions and controls are now responsible for updating the constraints for animations, but the view can handle that itself for interactions.

// upon it
return;
}
view.resolveConstraints(0);
Copy link
Member

@ahocevar ahocevar Apr 5, 2019

Choose a reason for hiding this comment

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

I'm wondering if a better place for this new line this would be somewhere in ol/View#animate().

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've thought about that as well but didn't manage to get it to work: it was either breaking the "smoothly return view in allowed extent/resolution" effect at the end of an interaction, or causing regressions in other places, depending on where I'd put it.

I agree this does not feel right. To have a cleaner system would mean some rework of the animate method IMO, which is a tricky task. The ideal solution would be to get rid of all these applyTargetState_ and resolveConstraints calls and only translate target values into actual view parameters on the main render loop (ans as such apply constraints only once per frame).

const newZoom = view.getConstrainedZoom(currentZoom + delta);
const newResolution = view.getResolutionForZoom(newZoom);

view.resolveConstraints(0);
Copy link
Member

Choose a reason for hiding this comment

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

Is this needed? Or will it still be needed if ol/View#animate() handles it (like I suggested in the previous comment)?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

See other comment

disposeMap(map);
});

it.only('works when initialized with #setCenter() and #setZoom()', function(done) {
Copy link
Member

Choose a reason for hiding this comment

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

The .only should be removed.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed

}, 500);
});

it.only('works when initialized with #animate()', function(done) {
Copy link
Member

Choose a reason for hiding this comment

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

.only also should be removed here.

Previously, an interaction could begin while target values
(center/resolution) were out of the allowed range, causing a
glitch where the view zoom/position would jump suddenly.
@jahow jahow force-pushed the fix-view-jump-glitch branch from 3b893fb to 0f73f16 Compare April 5, 2019 09:55
@jahow
Copy link
Contributor Author

jahow commented Apr 5, 2019

TL;DR: could not find a better way with the time & means available to me, sorry!

@ahocevar
Copy link
Member

ahocevar commented Apr 5, 2019

@jahow I finally wrapped my head around the new constraints system, and I think I came up with a good solution. Can you please let me know what you think about 070c1ec?

@jahow
Copy link
Contributor Author

jahow commented Apr 5, 2019

Works fine! well done

@ahocevar ahocevar merged commit c72f699 into openlayers:master Apr 5, 2019
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

Successfully merging this pull request may close these issues.

Unexpected animation when starting to interact with the map

2 participants