mirror of
https://github.com/konvajs/konva.git
synced 2025-04-05 20:48:28 +08:00
fix clientRect calculations
This commit is contained in:
parent
cda445552a
commit
3b22252cc3
@ -4,6 +4,9 @@ This project adheres to [Semantic Versioning](http://semver.org/).
|
||||
|
||||
## [Not released][Not released]
|
||||
|
||||
### Fixed
|
||||
- `getClientRect` calculations
|
||||
|
||||
## [1.2.0][2016-09-15]
|
||||
|
||||
## Added
|
||||
|
8
konva.js
8
konva.js
@ -3,7 +3,7 @@
|
||||
* Konva JavaScript Framework v1.2.1
|
||||
* http://konvajs.github.io/
|
||||
* Licensed under the MIT or GPL Version 2 licenses.
|
||||
* Date: Thu Sep 15 2016
|
||||
* Date: Fri Sep 16 2016
|
||||
*
|
||||
* Original work Copyright (C) 2011 - 2013 by Eric Rowell (KineticJS)
|
||||
* Modified work Copyright (C) 2014 - 2015 by Anton Lavrenov (Konva)
|
||||
@ -7418,7 +7418,7 @@
|
||||
* @returns {Boolean}
|
||||
*/
|
||||
hasStroke: function() {
|
||||
return !!(this.stroke());
|
||||
return this.strokeEnabled() && !!(this.stroke());
|
||||
},
|
||||
/**
|
||||
* determines if point is in the shape, regardless if other shapes are on top of it. Note: because
|
||||
@ -7480,8 +7480,8 @@
|
||||
var fillAndStrokeWidth = fillRect.width + strokeWidth;
|
||||
var fillAndStrokeHeight = fillRect.height + strokeWidth;
|
||||
|
||||
var shadowOffsetX = this.shadowOffsetX();
|
||||
var shadowOffsetY = this.shadowOffsetY();
|
||||
var shadowOffsetX = this.hasShadow() ? this.shadowOffsetX() : 0;
|
||||
var shadowOffsetY = this.hasShadow() ? this.shadowOffsetY() : 0;
|
||||
|
||||
var preWidth = fillAndStrokeWidth + Math.abs(shadowOffsetX);
|
||||
var preHeight = fillAndStrokeHeight + Math.abs(shadowOffsetY);
|
||||
|
8
konva.min.js
vendored
8
konva.min.js
vendored
File diff suppressed because one or more lines are too long
@ -143,7 +143,7 @@
|
||||
* @returns {Boolean}
|
||||
*/
|
||||
hasStroke: function() {
|
||||
return !!(this.stroke());
|
||||
return this.strokeEnabled() && !!(this.stroke());
|
||||
},
|
||||
/**
|
||||
* determines if point is in the shape, regardless if other shapes are on top of it. Note: because
|
||||
@ -205,8 +205,8 @@
|
||||
var fillAndStrokeWidth = fillRect.width + strokeWidth;
|
||||
var fillAndStrokeHeight = fillRect.height + strokeWidth;
|
||||
|
||||
var shadowOffsetX = this.shadowOffsetX();
|
||||
var shadowOffsetY = this.shadowOffsetY();
|
||||
var shadowOffsetX = this.hasShadow() ? this.shadowOffsetX() : 0;
|
||||
var shadowOffsetY = this.hasShadow() ? this.shadowOffsetY() : 0;
|
||||
|
||||
var preWidth = fillAndStrokeWidth + Math.abs(shadowOffsetX);
|
||||
var preHeight = fillAndStrokeHeight + Math.abs(shadowOffsetY);
|
||||
|
@ -1122,5 +1122,30 @@ suite('Shape', function() {
|
||||
assert.equal(clone.foo, CustomShape.prototype.foo);
|
||||
});
|
||||
|
||||
test('getClientRect should skip disabled attributes', function() {
|
||||
var stage = addStage();
|
||||
var layer = new Konva.Layer();
|
||||
var shape = new Konva.Rect({
|
||||
x: 200,
|
||||
y: 100,
|
||||
width: 100,
|
||||
height: 100,
|
||||
fill: 'green',
|
||||
stroke: 'black',
|
||||
strokeWidth: 4,
|
||||
strokeEnabled: false,
|
||||
shadowOffsetX: 10,
|
||||
shadowEnabled: false
|
||||
});
|
||||
|
||||
layer.add(shape);
|
||||
stage.add(layer);
|
||||
|
||||
var rect = shape.getClientRect();
|
||||
|
||||
assert.equal(rect.width, 100, 'should not effect width');
|
||||
assert.equal(rect.height, 100, 'should not effect width');
|
||||
});
|
||||
|
||||
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user