add icon popupAnchor option test for nonPhantom browsers (#5865)
This commit is contained in:
parent
919ead4288
commit
7e5cbceaa5
@ -194,39 +194,74 @@ describe('Popup', function () {
|
|||||||
expect(spy.callCount).to.be(2);
|
expect(spy.callCount).to.be(2);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should take into account icon popupAnchor option", function () {
|
describe('should take into account icon popupAnchor option on', function () {
|
||||||
var autoPanBefore = L.Popup.prototype.options.autoPan;
|
var latlng = new L.LatLng(55.8, 37.6);
|
||||||
L.Popup.prototype.options.autoPan = false;
|
var offset = new L.Point(20, 30);
|
||||||
var popupAnchorBefore = L.Icon.Default.prototype.options.popupAnchor;
|
var autoPanBefore;
|
||||||
L.Icon.Default.prototype.options.popupAnchor = [0, 0];
|
var popupAnchorBefore;
|
||||||
|
var icon;
|
||||||
|
var marker1;
|
||||||
|
var marker2;
|
||||||
|
|
||||||
var latlng = new L.LatLng(55.8, 37.6),
|
before(function () {
|
||||||
offset = new L.Point(20, 30),
|
autoPanBefore = L.Popup.prototype.options.autoPan;
|
||||||
icon = new L.DivIcon({popupAnchor: offset}),
|
L.Popup.prototype.options.autoPan = false;
|
||||||
marker1 = new L.Marker(latlng),
|
popupAnchorBefore = L.Icon.Default.prototype.options.popupAnchor;
|
||||||
marker2 = new L.Marker(latlng, {icon: icon});
|
L.Icon.Default.prototype.options.popupAnchor = [0, 0];
|
||||||
|
});
|
||||||
|
|
||||||
marker1.bindPopup('Popup').addTo(map);
|
beforeEach(function () {
|
||||||
marker1.openPopup();
|
icon = new L.DivIcon({popupAnchor: offset});
|
||||||
var defaultLeft = parseInt(marker1._popup._container.style.left, 10);
|
marker1 = new L.Marker(latlng);
|
||||||
var defaultBottom = parseInt(marker1._popup._container.style.bottom, 10);
|
marker2 = new L.Marker(latlng, {icon: icon});
|
||||||
marker2.bindPopup('Popup').addTo(map);
|
});
|
||||||
marker2.openPopup();
|
|
||||||
var offsetLeft = parseInt(marker2._popup._container.style.left, 10);
|
|
||||||
var offsetBottom = parseInt(marker2._popup._container.style.bottom, 10);
|
|
||||||
expect(offsetLeft - offset.x).to.eql(defaultLeft);
|
|
||||||
expect(offsetBottom + offset.y).to.eql(defaultBottom);
|
|
||||||
|
|
||||||
// Now retry passing a popup instance to bindPopup
|
after(function () {
|
||||||
marker2.bindPopup(new L.Popup());
|
L.Popup.prototype.options.autoPan = autoPanBefore;
|
||||||
marker2.openPopup();
|
L.Icon.Default.prototype.options.popupAnchor = popupAnchorBefore;
|
||||||
offsetLeft = parseInt(marker2._popup._container.style.left, 10);
|
});
|
||||||
offsetBottom = parseInt(marker2._popup._container.style.bottom, 10);
|
|
||||||
expect(offsetLeft - offset.x).to.eql(defaultLeft);
|
|
||||||
expect(offsetBottom + offset.y).to.eql(defaultBottom);
|
|
||||||
|
|
||||||
L.Popup.prototype.options.autoPan = autoPanBefore;
|
it.skipInNonPhantom("non-any3d browsers", function () {
|
||||||
L.Icon.Default.prototype.options.popupAnchor = popupAnchorBefore;
|
marker1.bindPopup('Popup').addTo(map);
|
||||||
|
marker1.openPopup();
|
||||||
|
var defaultLeft = parseInt(marker1._popup._container.style.left, 10);
|
||||||
|
var defaultBottom = parseInt(marker1._popup._container.style.bottom, 10);
|
||||||
|
marker2.bindPopup('Popup').addTo(map);
|
||||||
|
marker2.openPopup();
|
||||||
|
var offsetLeft = parseInt(marker2._popup._container.style.left, 10);
|
||||||
|
var offsetBottom = parseInt(marker2._popup._container.style.bottom, 10);
|
||||||
|
expect(offsetLeft - offset.x).to.eql(defaultLeft);
|
||||||
|
expect(offsetBottom + offset.y).to.eql(defaultBottom);
|
||||||
|
|
||||||
|
// Now retry passing a popup instance to bindPopup
|
||||||
|
marker2.bindPopup(new L.Popup());
|
||||||
|
marker2.openPopup();
|
||||||
|
offsetLeft = parseInt(marker2._popup._container.style.left, 10);
|
||||||
|
offsetBottom = parseInt(marker2._popup._container.style.bottom, 10);
|
||||||
|
expect(offsetLeft - offset.x).to.eql(defaultLeft);
|
||||||
|
expect(offsetBottom + offset.y).to.eql(defaultBottom);
|
||||||
|
});
|
||||||
|
|
||||||
|
it.skipInPhantom("any3d browsers", function () {
|
||||||
|
marker1.bindPopup('Popup').addTo(map);
|
||||||
|
marker1.openPopup();
|
||||||
|
var defaultLeft = marker1._popup._container._leaflet_pos.x;
|
||||||
|
var defaultTop = marker1._popup._container._leaflet_pos.y;
|
||||||
|
marker2.bindPopup('Popup').addTo(map);
|
||||||
|
marker2.openPopup();
|
||||||
|
var offsetLeft = marker2._popup._container._leaflet_pos.x;
|
||||||
|
var offsetTop = marker2._popup._container._leaflet_pos.y;
|
||||||
|
expect(offsetLeft - offset.x).to.eql(defaultLeft);
|
||||||
|
expect(offsetTop - offset.y).to.eql(defaultTop);
|
||||||
|
|
||||||
|
// Now retry passing a popup instance to bindPopup
|
||||||
|
marker2.bindPopup(new L.Popup());
|
||||||
|
marker2.openPopup();
|
||||||
|
offsetLeft = marker2._popup._container._leaflet_pos.x;
|
||||||
|
offsetTop = marker2._popup._container._leaflet_pos.y;
|
||||||
|
expect(offsetLeft - offset.x).to.eql(defaultLeft);
|
||||||
|
expect(offsetTop - offset.y).to.eql(defaultTop);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it("prevents an underlying map click for Layer", function () {
|
it("prevents an underlying map click for Layer", function () {
|
||||||
|
Loading…
Reference in New Issue
Block a user