various IE vectors fixes

This commit is contained in:
Vladimir Agafonkin 2013-12-13 18:04:41 -05:00
parent 4e33ce3e0a
commit 46c279c88f
3 changed files with 26 additions and 24 deletions

View File

@ -181,7 +181,7 @@ L.Browser.canvas = (function () {
}()); }());
L.canvas = function () { L.canvas = function () {
return new L.Canvas(); return L.Browser.canvas ? new L.Canvas() : null;
}; };
if (L.Browser.canvas) { if (L.Browser.canvas) {

View File

@ -45,7 +45,7 @@ L.SVG.include(!L.Browser.vml ? {} : {
container.appendChild(layer._path); container.appendChild(layer._path);
if (layer.options.clickable) { if (layer.options.clickable) {
this._initEvents(layer); this._initEvents(layer, container);
} }
this._updateStyle(layer); this._updateStyle(layer);
@ -65,8 +65,8 @@ L.SVG.include(!L.Browser.vml ? {} : {
options = layer.options, options = layer.options,
container = layer._container; container = layer._container;
container.stroked = options.stroke; container.stroked = !!options.stroke;
container.filled = options.fill; container.filled = !!options.fill;
if (options.stroke) { if (options.stroke) {
if (!stroke) { if (!stroke) {
@ -140,4 +140,6 @@ if (L.Browser.vml) {
}; };
} }
})(); })();
L.SVG.instance = L.svg();
} }

View File

@ -43,14 +43,14 @@ L.SVG = L.Renderer.extend({
}, },
_initPath: function (layer) { _initPath: function (layer) {
layer._path = L.SVG.create('path'); var path = layer._path = L.SVG.create('path');
if (layer.options.className) { if (layer.options.className) {
L.DomUtil.addClass(layer._path, layer.options.className); L.DomUtil.addClass(path, layer.options.className);
} }
if (layer.options.clickable) { if (layer.options.clickable) {
this._initEvents(layer); this._initEvents(layer, path);
} }
this._updateStyle(layer); this._updateStyle(layer);
@ -124,14 +124,14 @@ L.SVG = L.Renderer.extend({
}, },
// TODO remove duplication with L.Map // TODO remove duplication with L.Map
_initEvents: function (layer) { _initEvents: function (layer, el) {
L.DomUtil.addClass(layer._path, 'leaflet-clickable'); L.DomUtil.addClass(el, 'leaflet-clickable');
L.DomEvent.on(layer._path, 'click', layer._onMouseClick, layer); L.DomEvent.on(el, 'click', layer._onMouseClick, layer);
var events = ['dblclick', 'mousedown', 'mouseover', 'mouseout', 'mousemove', 'contextmenu']; var events = ['dblclick', 'mousedown', 'mouseover', 'mouseout', 'mousemove', 'contextmenu'];
for (var i = 0; i < events.length; i++) { for (var i = 0; i < events.length; i++) {
L.DomEvent.on(layer._path, events[i], layer._fireMouseEvent, layer); L.DomEvent.on(el, events[i], layer._fireMouseEvent, layer);
} }
} }
}); });
@ -142,22 +142,22 @@ L.extend(L.SVG, {
return document.createElementNS('http://www.w3.org/2000/svg', name); return document.createElementNS('http://www.w3.org/2000/svg', name);
}, },
pointsToPath: function (points, closed) { pointsToPath: function (rings, closed) {
var flat = points[0] instanceof L.Point, var str = '',
str = ''; i, j, len, len2, points, p;
for (var i = 0, len = points.length, p; i < len; i++) { for (i = 0, len = rings.length; i < len; i++) {
p = points[i]; points = rings[i];
str += flat ? (i ? 'L' : 'M') + p.x + ' ' + p.y : L.SVG.pointsToPath(p, closed);
for (j = 0, len2 = points.length; j < len2; j++) {
p = points[j];
str += (j ? 'L' : 'M') + Math.round(p.x) + ' ' + Math.round(p.y);
} }
str = str || 'M0 0'; str += closed ? (L.Browser.svg ? 'z' : 'x') : '';
if (closed) {
str += L.Browser.svg ? 'z' : 'x';
} }
return str; return str || 'M0 0';
} }
}); });