mirror of
https://github.com/konvajs/konva.git
synced 2025-06-28 15:23:44 +08:00
fix "same value" detection in setAttr. fix #378
This commit is contained in:
parent
76d3282fcf
commit
f8bd25cbfe
@ -19,6 +19,7 @@ This project adheres to [Semantic Versioning](http://semver.org/).
|
|||||||
|
|
||||||
* some bugs fixes for `group.getClientRect()`
|
* some bugs fixes for `group.getClientRect()`
|
||||||
* `Konva.Arrow` will not draw dash for pointers
|
* `Konva.Arrow` will not draw dash for pointers
|
||||||
|
* setAttr will trigger change event if new value is the same Object
|
||||||
|
|
||||||
## [2.0.2][2018-03-15]
|
## [2.0.2][2018-03-15]
|
||||||
|
|
||||||
|
12
konva.js
12
konva.js
@ -352,7 +352,10 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Transform constructor
|
* Transform constructor. Transform object is a private class of Konva framework.
|
||||||
|
* In most of the cases you don't need to use it in your app.
|
||||||
|
* But there is a documentation for that class in case you still want
|
||||||
|
* to make some manual calculations.
|
||||||
* @constructor
|
* @constructor
|
||||||
* @param {Array} [m] Optional six-element matrix
|
* @param {Array} [m] Optional six-element matrix
|
||||||
* @memberof Konva
|
* @memberof Konva
|
||||||
@ -732,6 +735,10 @@
|
|||||||
_isString: function(obj) {
|
_isString: function(obj) {
|
||||||
return Object.prototype.toString.call(obj) === OBJECT_STRING;
|
return Object.prototype.toString.call(obj) === OBJECT_STRING;
|
||||||
},
|
},
|
||||||
|
// arrays are objects too
|
||||||
|
isObject: function(val) {
|
||||||
|
return val instanceof Object;
|
||||||
|
},
|
||||||
isValidSelector: function(selector) {
|
isValidSelector: function(selector) {
|
||||||
if (typeof selector !== 'string') {
|
if (typeof selector !== 'string') {
|
||||||
return false;
|
return false;
|
||||||
@ -4244,7 +4251,8 @@
|
|||||||
_setAttr: function(key, val) {
|
_setAttr: function(key, val) {
|
||||||
var oldVal;
|
var oldVal;
|
||||||
oldVal = this.attrs[key];
|
oldVal = this.attrs[key];
|
||||||
if (oldVal === val) {
|
var same = oldVal === val;
|
||||||
|
if (same && !Konva.Util.isObject(val)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (val === undefined || val === null) {
|
if (val === undefined || val === null) {
|
||||||
|
2
konva.min.js
vendored
2
konva.min.js
vendored
File diff suppressed because one or more lines are too long
@ -1879,7 +1879,8 @@
|
|||||||
_setAttr: function(key, val) {
|
_setAttr: function(key, val) {
|
||||||
var oldVal;
|
var oldVal;
|
||||||
oldVal = this.attrs[key];
|
oldVal = this.attrs[key];
|
||||||
if (oldVal === val) {
|
var same = oldVal === val;
|
||||||
|
if (same && !Konva.Util.isObject(val)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (val === undefined || val === null) {
|
if (val === undefined || val === null) {
|
||||||
|
@ -107,7 +107,10 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Transform constructor
|
* Transform constructor. Transform object is a private class of Konva framework.
|
||||||
|
* In most of the cases you don't need to use it in your app.
|
||||||
|
* But there is a documentation for that class in case you still want
|
||||||
|
* to make some manual calculations.
|
||||||
* @constructor
|
* @constructor
|
||||||
* @param {Array} [m] Optional six-element matrix
|
* @param {Array} [m] Optional six-element matrix
|
||||||
* @memberof Konva
|
* @memberof Konva
|
||||||
@ -487,6 +490,10 @@
|
|||||||
_isString: function(obj) {
|
_isString: function(obj) {
|
||||||
return Object.prototype.toString.call(obj) === OBJECT_STRING;
|
return Object.prototype.toString.call(obj) === OBJECT_STRING;
|
||||||
},
|
},
|
||||||
|
// arrays are objects too
|
||||||
|
isObject: function(val) {
|
||||||
|
return val instanceof Object;
|
||||||
|
},
|
||||||
isValidSelector: function(selector) {
|
isValidSelector: function(selector) {
|
||||||
if (typeof selector !== 'string') {
|
if (typeof selector !== 'string') {
|
||||||
return false;
|
return false;
|
||||||
|
@ -309,4 +309,34 @@ suite('Line', function() {
|
|||||||
layer2.hide();
|
layer2.hide();
|
||||||
compareLayers(layer, layer2);
|
compareLayers(layer, layer2);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('updating points with old mutable array should trigger recalculations', function() {
|
||||||
|
var stage = addStage();
|
||||||
|
var layer = new Konva.Layer();
|
||||||
|
|
||||||
|
var points = [-25, 50, 250, -30, 150, 50];
|
||||||
|
var blob = new Konva.Line({
|
||||||
|
x: 50,
|
||||||
|
y: 50,
|
||||||
|
points: points,
|
||||||
|
stroke: 'blue',
|
||||||
|
strokeWidth: 10,
|
||||||
|
draggable: true,
|
||||||
|
closed: true,
|
||||||
|
tension: 1
|
||||||
|
});
|
||||||
|
|
||||||
|
var tensionPoints = blob.getTensionPoints();
|
||||||
|
points.push(250, 100);
|
||||||
|
blob.setPoints(points);
|
||||||
|
|
||||||
|
layer.add(blob);
|
||||||
|
stage.add(layer);
|
||||||
|
|
||||||
|
assert.equal(
|
||||||
|
tensionPoints === blob.getTensionPoints(),
|
||||||
|
false,
|
||||||
|
'calculated points should change'
|
||||||
|
);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user