From 5bf0f0e8b7020a1b317c46f077c8926664387e74 Mon Sep 17 00:00:00 2001 From: mourner Date: Fri, 21 Oct 2011 19:39:35 +0300 Subject: [PATCH] fix vector flickering in Safari on big maps --- dist/leaflet.js | 4 ++-- src/layer/vector/Path.SVG.js | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/dist/leaflet.js b/dist/leaflet.js index 8186acd1..d8f60a04 100644 --- a/dist/leaflet.js +++ b/dist/leaflet.js @@ -94,8 +94,8 @@ L.Path=L.Path.extend({statics:{SVG:L.Browser.svg,_createElement:function(a){retu "round"),this._path.setAttribute("stroke-linecap","round"));this.options.fill?this._path.setAttribute("fill-rule","evenodd"):this._path.setAttribute("fill","none");this._updateStyle()},_updateStyle:function(){this.options.stroke&&(this._path.setAttribute("stroke",this.options.color),this._path.setAttribute("stroke-opacity",this.options.opacity),this._path.setAttribute("stroke-width",this.options.weight));this.options.fill&&(this._path.setAttribute("fill",this.options.fillColor||this.options.color), this._path.setAttribute("fill-opacity",this.options.fillOpacity))},_updatePath:function(){var a=this.getPathString();a||(a="M0 0");this._path.setAttribute("d",a)},_initEvents:function(){if(this.options.clickable){L.Browser.vml||this._path.setAttribute("class","leaflet-clickable");L.DomEvent.addListener(this._container,"click",this._onMouseClick,this);for(var a=["dblclick","mousedown","mouseover","mouseout","mousemove"],b=0;b';a=a.firstChild;a.style.behavior="url(#default#VML)";return a&&typeof a.adj=="object"}(); +L.Map.include({_initPathRoot:function(){if(!this._pathRoot)this._pathRoot=L.Path._createElement("svg"),this._panes.overlayPane.appendChild(this._pathRoot),this.on("moveend",this._updateSvgViewport),this._updateSvgViewport()},_updateSvgViewport:function(){this._updatePathViewport();var a=this._pathViewport,b=a.min,c=a.max,a=c.x-b.x,c=c.y-b.y,d=this._pathRoot,e=this._panes.overlayPane;L.Browser.webkit&&e.removeChild(d);L.DomUtil.setPosition(d,b);d.setAttribute("width",a);d.setAttribute("height",c); +d.setAttribute("viewBox",[b.x,b.y,a,c].join(" "));L.Browser.webkit&&e.appendChild(d)}});L.Browser.vml=function(){var a=document.createElement("div");a.innerHTML='';a=a.firstChild;a.style.behavior="url(#default#VML)";return a&&typeof a.adj=="object"}(); L.Path=L.Browser.svg||!L.Browser.vml?L.Path:L.Path.extend({statics:{VML:!0,CLIP_PADDING:0.02,_createElement:function(){try{return document.namespaces.add("lvml","urn:schemas-microsoft-com:vml"),function(a){return document.createElement("')}}catch(a){return function(a){return document.createElement("<"+a+' xmlns="urn:schemas-microsoft.com:vml" class="lvml">')}}}()},_initPath:function(){this._container=L.Path._createElement("shape");this._container.className+=" leaflet-vml-shape"+ (this.options.clickable?" leaflet-clickable":"");this._container.coordsize="1 1";this._path=L.Path._createElement("path");this._container.appendChild(this._path);this._map._pathRoot.appendChild(this._container)},_initStyle:function(){this.options.stroke?(this._stroke=L.Path._createElement("stroke"),this._stroke.endcap="round",this._container.appendChild(this._stroke)):this._container.stroked=!1;this.options.fill?(this._container.filled=!0,this._fill=L.Path._createElement("fill"),this._container.appendChild(this._fill)): this._container.filled=!1;this._updateStyle()},_updateStyle:function(){if(this.options.stroke)this._stroke.weight=this.options.weight+"px",this._stroke.color=this.options.color,this._stroke.opacity=this.options.opacity;if(this.options.fill)this._fill.color=this.options.fillColor||this.options.color,this._fill.opacity=this.options.fillOpacity},_updatePath:function(){this._container.style.display="none";this._path.v=this.getPathString()+" ";this._container.style.display=""}}); diff --git a/src/layer/vector/Path.SVG.js b/src/layer/vector/Path.SVG.js index 7b2b730c..5ad154ae 100644 --- a/src/layer/vector/Path.SVG.js +++ b/src/layer/vector/Path.SVG.js @@ -118,13 +118,13 @@ L.Map.include({ // Hack to make flicker on drag end on mobile webkit less irritating // Unfortunately I haven't found a good workaround for this yet - if (L.Browser.mobileWebkit) { pane.removeChild(root); } + if (L.Browser.webkit) { pane.removeChild(root); } L.DomUtil.setPosition(root, min); root.setAttribute('width', width); root.setAttribute('height', height); root.setAttribute('viewBox', [min.x, min.y, width, height].join(' ')); - if (L.Browser.mobileWebkit) { pane.appendChild(root); } + if (L.Browser.webkit) { pane.appendChild(root); } } }); \ No newline at end of file