horrible hacks to fix iOS Safari bugging out hw-acceleration

This commit is contained in:
Vladimir Agafonkin 2014-01-14 16:29:39 +02:00
parent cfde916edf
commit 592d2ce8f4
2 changed files with 15 additions and 0 deletions

5
dist/leaflet.css vendored
View File

@ -140,6 +140,11 @@
opacity: 1; opacity: 1;
} }
.leaflet-hack {
width: 1px;
height: 1px;
}
.leaflet-zoom-anim .leaflet-zoom-animated { .leaflet-zoom-anim .leaflet-zoom-animated {
-webkit-transition: -webkit-transform 0.25s cubic-bezier(0,0,0.25,1); -webkit-transition: -webkit-transform 0.25s cubic-bezier(0,0,0.25,1);
-moz-transition: -moz-transform 0.25s cubic-bezier(0,0,0.25,1); -moz-transition: -moz-transform 0.25s cubic-bezier(0,0,0.25,1);

View File

@ -171,6 +171,8 @@ L.GridLayer = L.Layer.extend({
this._bgBuffer = L.DomUtil.create('div', className, this._container); this._bgBuffer = L.DomUtil.create('div', className, this._container);
this._tileContainer = L.DomUtil.create('div', className, this._container); this._tileContainer = L.DomUtil.create('div', className, this._container);
L.DomUtil.setTransform(this._tileContainer);
} else { } else {
this._tileContainer = this._container; this._tileContainer = this._container;
} }
@ -297,6 +299,14 @@ L.GridLayer = L.Layer.extend({
for (i = 0; i < tilesToLoad; i++) { for (i = 0; i < tilesToLoad; i++) {
this._addTile(queue[i], fragment); this._addTile(queue[i], fragment);
} }
if (this._zoomAnimated) {
// a pretty funny hack - Safari bugs out with HW-acceleration when you pan to the right
// and there are no elements in the top left corner of the tile container, this fixes it
var hack = L.DomUtil.create('div', 'leaflet-hack', this._tileContainer);
L.DomUtil.setTransform(hack);
}
this._tileContainer.appendChild(fragment); this._tileContainer.appendChild(fragment);
}, },