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

Removed zoomAnimation option #4699

Closed
wants to merge 1 commit into from
Closed

Conversation

fnicollet
Copy link
Collaborator

Removed zoomAnimation option in Popup
Fixes #4685

@IvanSanchez
Copy link
Member

@fnicollet The unit tests are failing with the same symptoms I (and @yohanboniface) noticed today - we might need to check the popup offset manually before merging.

@fnicollet
Copy link
Collaborator Author

Yes, I would say that this commit is the source of the unit test failing:
bddfb11

@fnicollet
Copy link
Collaborator Author

Ok, I think I am beginning to understand. Before my PR, the tests fail when zoomAnimated is true, but succeed when zoomAnimated is false. The test is not just one the Popup's zoomAnimation :

this._zoomAnimated = this._zoomAnimated && this.options.zoomAnimation;

but also on "this._zoomAnimated", which comes from Layer.js:
https://github.com/Leaflet/Leaflet/blob/master/src/layer/Layer.js#L86

So it takes in account map's zoomAnimation. So my guess is that when running the tests in phantom, the map is set as not animated, probably this test is failing in that env:
https://github.com/Leaflet/Leaflet/blob/master/src/map/anim/Map.ZoomAnimation.js#L18

So basically, the tests have been written for the zoomAnimation=false edge case and not the zoomAnimation=true default case.

So I would say, let's fix the tests instead?

@fnicollet
Copy link
Collaborator Author

Should this test be removed?

It tests for marker1._popup._container.style.left, which now always depends on the popup's width/height but doesn't give any indication of the popup's position relative to its anchor
Because we are now in the zoomAnimated case, the popup's position is changed via "L.DomUtil.setPosition", which changes the CSS transform property and not the left/bottom properties.

So I would ditch this test. Tell me if you want me to add it to the PR

@yohanboniface
Copy link
Member

@fnicollet popup positioning would certainly deserve a bit of cleaning, but AFAIK even with your commit we are setting the bottom and left manually. So this test should pass IMHO.
Certainly, even when in zoomAnimated, we should take care of updating the offset with the anchor.

@@ -362,11 +353,7 @@ L.Popup = L.Layer.extend({
offset = L.point(this.options.offset),
anchor = this._getAnchor();
Copy link
Member

Choose a reason for hiding this comment

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

This should fix the failing test:

            anchor = this._getAnchor(),
            offset = L.point(this.options.offset).add(anchor),

Copy link
Member

@yohanboniface yohanboniface Jul 1, 2016

Choose a reason for hiding this comment

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

Actually, _add instead of add to prevent a useless Point cloning.

@yohanboniface
Copy link
Member

yohanboniface commented Jul 1, 2016

Though I think we may have an issue when L.Browser.any3d is false.

@fnicollet
Copy link
Collaborator Author

Here is what I understood from the code:
This specific Spec tests the facts that popupAnchor is well interpreted. It does so by comparing the position of a popup with and without a "popupAnchor" on the icon.

  • "popupAnchor" has an effect on _getAnchor, which drives the CSS transform of the container
  • "offset" has no relationship with popupAnchor, it just affects the bottom/left properties of the container.

Both combined achieve the final placement of the popup. So if the test really wants to test popupAnchor, it should be changed to a test which account for both (using element.offsetLeft or something?) or removed

@fnicollet
Copy link
Collaborator Author

Just saw your other comment, there will indeed be an issue if L.Browser.any3d is false as setPosition will change top left, and then it will set left/bottom right after and override what's been done in setPosition.

@@ -286,7 +277,7 @@ L.Popup = L.Layer.extend({
var prefix = 'leaflet-popup',
container = this._container = L.DomUtil.create('div',
prefix + ' ' + (this.options.className || '') +
' leaflet-zoom-' + (this._zoomAnimated ? 'animated' : 'hide'));
Copy link
Member

Choose a reason for hiding this comment

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

I think we want to keep that.
Even if the Popup itself does not have a zoomAnimation option, we want to listen to the animation capabilities of the browser and hide the popup when no animation will be made.

@IvanSanchez
Copy link
Member

Unable to merge due to conflicts with the new tooltip/divoverlay code. Superseded by #4685

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.

4 participants