[Pkg-javascript-commits] [leaflet] 55/78: Possible change for #200 - Adding support for dashArray for line canvas rendering

Jonas Smedegaard dr at jones.dk
Sat May 7 08:58:47 UTC 2016


This is an automated email from the git hooks/post-receive script.

js pushed a commit to branch master
in repository leaflet.

commit b1194a4fafce491f1a99aa6100c53c139ec15c4e
Author: Colin Goudie <colin.goudie at tributech.com.au>
Date:   Mon Jan 25 18:40:49 2016 +1100

    Possible change for #200 - Adding support for dashArray for line canvas rendering
    
    Some changes from review
    
    Refactoring an if block
---
 src/layer/vector/canvas/Path.Canvas.js | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/src/layer/vector/canvas/Path.Canvas.js b/src/layer/vector/canvas/Path.Canvas.js
index 291263b..83a625e 100644
--- a/src/layer/vector/canvas/Path.Canvas.js
+++ b/src/layer/vector/canvas/Path.Canvas.js
@@ -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();
@@ -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;
 
@@ -80,6 +87,7 @@ 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 () {
@@ -87,6 +95,8 @@ L.Path = (L.Path.SVG && !window.L_PREFER_CANVAS) || !L.Browser.canvas ? L.Path :
 
 		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];

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/leaflet.git



More information about the Pkg-javascript-commits mailing list