mirror of
https://github.com/konvajs/konva.git
synced 2025-06-28 15:23:44 +08:00
Merge branch 'seethroughtrees-feature/arrow'
This commit is contained in:
commit
43e628680c
19
konva.js
19
konva.js
@ -2,7 +2,7 @@
|
|||||||
* Konva JavaScript Framework v2.0.2
|
* Konva JavaScript Framework v2.0.2
|
||||||
* http://konvajs.github.io/
|
* http://konvajs.github.io/
|
||||||
* Licensed under the MIT
|
* Licensed under the MIT
|
||||||
* Date: Thu Mar 29 2018
|
* Date: Mon Apr 02 2018
|
||||||
*
|
*
|
||||||
* Original work Copyright (C) 2011 - 2013 by Eric Rowell (KineticJS)
|
* Original work Copyright (C) 2011 - 2013 by Eric Rowell (KineticJS)
|
||||||
* Modified work Copyright (C) 2014 - present by Anton Lavrenov (Konva)
|
* Modified work Copyright (C) 2014 - present by Anton Lavrenov (Konva)
|
||||||
@ -18529,7 +18529,24 @@
|
|||||||
ctx.closePath();
|
ctx.closePath();
|
||||||
ctx.restore();
|
ctx.restore();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// here is a tricky part
|
||||||
|
// we need to disable dash for arrow pointers
|
||||||
|
var isDashEnabled = this.dashEnabled();
|
||||||
|
if (isDashEnabled) {
|
||||||
|
// manually disable dash for head
|
||||||
|
// it is better not to use setter here,
|
||||||
|
// because it will trigger attr change event
|
||||||
|
this.attrs.dashEnabled = false;
|
||||||
|
ctx.setLineDash([]);
|
||||||
|
}
|
||||||
|
|
||||||
ctx.fillStrokeShape(this);
|
ctx.fillStrokeShape(this);
|
||||||
|
|
||||||
|
// restore old value
|
||||||
|
if (isDashEnabled) {
|
||||||
|
this.attrs.dashEnabled = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
4
konva.min.js
vendored
4
konva.min.js
vendored
File diff suppressed because one or more lines are too long
@ -66,7 +66,24 @@
|
|||||||
ctx.closePath();
|
ctx.closePath();
|
||||||
ctx.restore();
|
ctx.restore();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// here is a tricky part
|
||||||
|
// we need to disable dash for arrow pointers
|
||||||
|
var isDashEnabled = this.dashEnabled();
|
||||||
|
if (isDashEnabled) {
|
||||||
|
// manually disable dash for head
|
||||||
|
// it is better not to use setter here,
|
||||||
|
// because it will trigger attr change event
|
||||||
|
this.attrs.dashEnabled = false;
|
||||||
|
ctx.setLineDash([]);
|
||||||
|
}
|
||||||
|
|
||||||
ctx.fillStrokeShape(this);
|
ctx.fillStrokeShape(this);
|
||||||
|
|
||||||
|
// restore old value
|
||||||
|
if (isDashEnabled) {
|
||||||
|
this.attrs.dashEnabled = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -35,4 +35,31 @@ suite('Arrow', function() {
|
|||||||
layer.draw();
|
layer.draw();
|
||||||
showHit(layer);
|
showHit(layer);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('do not draw dash for head', function() {
|
||||||
|
var stage = addStage();
|
||||||
|
var layer = new Konva.Layer();
|
||||||
|
|
||||||
|
var arrow = new Konva.Arrow({
|
||||||
|
points: [50, 50, 100, 100],
|
||||||
|
stroke: 'red',
|
||||||
|
fill: 'blue',
|
||||||
|
strokeWidth: 5,
|
||||||
|
pointerWidth: 20,
|
||||||
|
pointerLength: 20,
|
||||||
|
dash: [5, 5]
|
||||||
|
});
|
||||||
|
|
||||||
|
layer.add(arrow);
|
||||||
|
stage.add(layer);
|
||||||
|
|
||||||
|
var trace = layer.getContext().getTrace();
|
||||||
|
|
||||||
|
// console.log(trace);
|
||||||
|
|
||||||
|
assert.equal(
|
||||||
|
trace,
|
||||||
|
'clearRect(0,0,578,200);save();transform(1,0,0,1,0,0);beginPath();moveTo(50,50);lineTo(100,100);setLineDash(5,5);lineDashOffset=0;lineWidth=5;strokeStyle=red;stroke();save();beginPath();translate(100,100);rotate(0.785);moveTo(0,0);lineTo(-20,10);lineTo(-20,-10);closePath();restore();setLineDash();fillStyle=blue;fill();lineWidth=5;strokeStyle=red;stroke();restore();'
|
||||||
|
);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user