Skip to content

Commit

Permalink
Possible change for Leaflet#200 - Adding support for dashArray for li…
Browse files Browse the repository at this point in the history
…ne canvas rendering

Some changes from review

Refactoring an if block
  • Loading branch information
gommo committed Feb 21, 2016
1 parent 3543fc6 commit b1194a4
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/layer/vector/canvas/Path.Canvas.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ L.Path = (L.Path.SVG && !window.L_PREFER_CANVAS) || !L.Browser.canvas ? L.Path :

setStyle: function (style) {
L.setOptions(this, style);
this._addLineDash();

if (this._map) {
this._updateStyle();
Expand Down Expand Up @@ -63,6 +64,12 @@ L.Path = (L.Path.SVG && !window.L_PREFER_CANVAS) || !L.Browser.canvas ? L.Path :
this._ctx = this._map._canvasCtx;
},

_addLineDash: function() {
if (this.options.dashArray) {
this.options._dashArray = this.options.dashArray.split(',').map(Number);
}
},

_updateStyle: function () {
var options = this.options;

Expand All @@ -80,13 +87,16 @@ L.Path = (L.Path.SVG && !window.L_PREFER_CANVAS) || !L.Browser.canvas ? L.Path :
if (options.lineJoin) {
this._ctx.lineJoin = options.lineJoin;
}
this._addLineDash();
},

_drawPath: function () {
var i, j, len, len2, point, drawMethod;

this._ctx.beginPath();

this._ctx.setLineDash(this.options && this.options._dashArray || []);

for (i = 0, len = this._parts.length; i < len; i++) {
for (j = 0, len2 = this._parts[i].length; j < len2; j++) {
point = this._parts[i][j];
Expand Down

0 comments on commit b1194a4

Please sign in to comment.