mirror of
https://github.com/konvajs/konva.git
synced 2025-12-19 10:58:20 +08:00
optimize change event. close #120
This commit is contained in:
@@ -18,6 +18,7 @@ This project adheres to [Semantic Versioning](http://semver.org/).
|
|||||||
### Changed
|
### Changed
|
||||||
- `moveTo` and some other methods return `this`
|
- `moveTo` and some other methods return `this`
|
||||||
- `getAbsolutePosition` support optional relative parent argument (useful to find absolute position inside of some of parent nodes)
|
- `getAbsolutePosition` support optional relative parent argument (useful to find absolute position inside of some of parent nodes)
|
||||||
|
- `change` event will be not fired if changed value is the same as old value
|
||||||
|
|
||||||
## [0.10.0][2015-10-27]
|
## [0.10.0][2015-10-27]
|
||||||
|
|
||||||
|
|||||||
5
konva.js
5
konva.js
@@ -3,7 +3,7 @@
|
|||||||
* Konva JavaScript Framework v0.11.0
|
* Konva JavaScript Framework v0.11.0
|
||||||
* http://konvajs.github.io/
|
* http://konvajs.github.io/
|
||||||
* Licensed under the MIT or GPL Version 2 licenses.
|
* Licensed under the MIT or GPL Version 2 licenses.
|
||||||
* Date: Mon Jan 04 2016
|
* Date: Thu Jan 07 2016
|
||||||
*
|
*
|
||||||
* 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 - 2015 by Anton Lavrenov (Konva)
|
* Modified work Copyright (C) 2014 - 2015 by Anton Lavrenov (Konva)
|
||||||
@@ -3969,6 +3969,9 @@
|
|||||||
var oldVal;
|
var oldVal;
|
||||||
if(val !== undefined) {
|
if(val !== undefined) {
|
||||||
oldVal = this.attrs[key];
|
oldVal = this.attrs[key];
|
||||||
|
if (oldVal === val) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
this.attrs[key] = val;
|
this.attrs[key] = val;
|
||||||
this._fireChangeEvent(key, oldVal, val);
|
this._fireChangeEvent(key, oldVal, val);
|
||||||
}
|
}
|
||||||
|
|||||||
4
konva.min.js
vendored
4
konva.min.js
vendored
File diff suppressed because one or more lines are too long
@@ -1732,6 +1732,9 @@
|
|||||||
var oldVal;
|
var oldVal;
|
||||||
if(val !== undefined) {
|
if(val !== undefined) {
|
||||||
oldVal = this.attrs[key];
|
oldVal = this.attrs[key];
|
||||||
|
if (oldVal === val) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
this.attrs[key] = val;
|
this.attrs[key] = val;
|
||||||
this._fireChangeEvent(key, oldVal, val);
|
this._fireChangeEvent(key, oldVal, val);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -696,6 +696,36 @@ suite('Node', function() {
|
|||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// ======================================================
|
||||||
|
test('test on attr change for same value', function() {
|
||||||
|
var stage = addStage();
|
||||||
|
var layer = new Konva.Layer();
|
||||||
|
var rect = new Konva.Rect({
|
||||||
|
x: 50,
|
||||||
|
y: 50,
|
||||||
|
width: 200,
|
||||||
|
height: 50,
|
||||||
|
fill: 'blue',
|
||||||
|
shadowOffset: {x: 10, y: 10},
|
||||||
|
});
|
||||||
|
|
||||||
|
layer.add(rect);
|
||||||
|
stage.add(layer);
|
||||||
|
|
||||||
|
var widthChanged = 0;
|
||||||
|
|
||||||
|
rect.on('widthChange', function(evt) {
|
||||||
|
widthChanged++;
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
rect.width(210);
|
||||||
|
rect.width(210);
|
||||||
|
|
||||||
|
assert.equal(widthChanged, 1, 'should trigger only once');
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
// ======================================================
|
// ======================================================
|
||||||
test('set shape, layer and stage opacity to 0.5', function() {
|
test('set shape, layer and stage opacity to 0.5', function() {
|
||||||
var stage = addStage();
|
var stage = addStage();
|
||||||
|
|||||||
Reference in New Issue
Block a user