This commit is contained in:
lavrton 2015-02-03 10:40:32 +07:00
parent b7c5bb02c0
commit d48439b952
5 changed files with 16 additions and 15 deletions

View File

@ -4,7 +4,7 @@
* fixed when browser is crashing on pointer events fixed (and optimized `getIntersection` function) * fixed when browser is crashing on pointer events fixed (and optimized `getIntersection` function)
* Enhancements * Enhancements
* `container.findOne()` method * `container.findOne()` method
* new `strokeHit` property. Useful for performance optimizations * new `strokeHitEnabled` property. Useful for performance optimizations

View File

@ -38,6 +38,7 @@
* @param {Integer} [config.strokeBlue] set stroke blue component * @param {Integer} [config.strokeBlue] set stroke blue component
* @param {Integer} [config.strokeAlpha] set stroke alpha component * @param {Integer} [config.strokeAlpha] set stroke alpha component
* @param {Number} [config.strokeWidth] stroke width * @param {Number} [config.strokeWidth] stroke width
* @param {Boolean} [config.strokeHitEnabled] flag which enables or disables stroke hit region. The default is true
* @param {Boolean} [config.strokeScaleEnabled] flag which enables or disables stroke scale. The default is true * @param {Boolean} [config.strokeScaleEnabled] flag which enables or disables stroke scale. The default is true
* @param {Boolean} [config.strokeEnabled] flag which enables or disables the stroke. The default value is true * @param {Boolean} [config.strokeEnabled] flag which enables or disables the stroke. The default value is true
* @param {String} [config.lineJoin] can be miter, round, or bevel. The default * @param {String} [config.lineJoin] can be miter, round, or bevel. The default

View File

@ -580,7 +580,7 @@
this.restore(); this.restore();
}, },
_stroke: function(shape) { _stroke: function(shape) {
if(shape.hasStroke() && shape.strokeHit()) { if(shape.hasStroke() && shape.strokeHitEnabled()) {
// ignore strokeScaleEnabled for Text // ignore strokeScaleEnabled for Text
var strokeScaleEnabled = (shape.getStrokeScaleEnabled() || (shape instanceof Konva.Text)); var strokeScaleEnabled = (shape.getStrokeScaleEnabled() || (shape instanceof Konva.Text));
if (!strokeScaleEnabled) { if (!strokeScaleEnabled) {

View File

@ -428,25 +428,25 @@
* shape.strokeWidth(); * shape.strokeWidth();
*/ */
Konva.Factory.addGetterSetter(Konva.Shape, 'strokeHit', true); Konva.Factory.addGetterSetter(Konva.Shape, 'strokeHitEnabled', true);
/** /**
* get/set stroke hit property. Useful for performance optimization. * get/set strokeHitEnabled property. Useful for performance optimization.
* You may set `shape.strokeHit(false)`. In this case stroke will be no draw on hit canvas, so hit area * You may set `shape.strokeHitEnabled(false)`. In this case stroke will be no draw on hit canvas, so hit area
* of shape will be decreased (by lineWidth / 2). Remember that non closed line with `strokeHit = false` * of shape will be decreased (by lineWidth / 2). Remember that non closed line with `strokeHitEnabled = false`
* will be not drawn on hit canvas, that is mean line will no trigger pointer events (like mouseover) * will be not drawn on hit canvas, that is mean line will no trigger pointer events (like mouseover)
* Default value is true * Default value is true
* @name strokeHit * @name strokeHitEnabled
* @method * @method
* @memberof Konva.Shape.prototype * @memberof Konva.Shape.prototype
* @param {Boolean} strokeHit * @param {Boolean} strokeHitEnabled
* @returns {Boolean} * @returns {Boolean}
* @example * @example
* // get strokeHit * // get strokeHitEnabled
* var strokeHit = shape.strokeHit(); * var strokeHitEnabled = shape.strokeHitEnabled();
* *
* // set strokeHit * // set strokeHitEnabled
* shape.strokeHit(); * shape.strokeHitEnabled();
*/ */
Konva.Factory.addGetterSetter(Konva.Shape, 'lineJoin'); Konva.Factory.addGetterSetter(Konva.Shape, 'lineJoin');

View File

@ -855,10 +855,10 @@ suite('Shape', function() {
strokeWidth: 20 strokeWidth: 20
}); });
// default value // default value
assert.equal(rect.strokeHit(), true); assert.equal(rect.strokeHitEnabled(), true);
rect.strokeHit(false); rect.strokeHitEnabled(false);
assert.equal(rect.strokeHit(), false); assert.equal(rect.strokeHitEnabled(), false);
layer.add(rect); layer.add(rect);
stage.add(layer); stage.add(layer);