mirror of
https://github.com/konvajs/konva.git
synced 2025-09-18 18:27:58 +08:00
bug fix: ellipse radius change no longer fires duplicate attr change event
This commit is contained in:
10
dist/kinetic-core.js
vendored
10
dist/kinetic-core.js
vendored
@@ -3433,10 +3433,12 @@ Kinetic.Ellipse.prototype = {
|
||||
if(go._isObject(radius)) {
|
||||
return false;
|
||||
}
|
||||
var pos = go._getXY(radius);
|
||||
this.setAttrs({
|
||||
radius: pos
|
||||
});
|
||||
|
||||
/*
|
||||
* directly set radius attr to avoid
|
||||
* duplicate attr change event
|
||||
*/
|
||||
this.attrs.radius = go._getXY(radius);
|
||||
}
|
||||
};
|
||||
// extend Shape
|
||||
|
2
dist/kinetic-core.min.js
vendored
2
dist/kinetic-core.min.js
vendored
File diff suppressed because one or more lines are too long
@@ -56,10 +56,12 @@ Kinetic.Ellipse.prototype = {
|
||||
if(go._isObject(radius)) {
|
||||
return false;
|
||||
}
|
||||
var pos = go._getXY(radius);
|
||||
this.setAttrs({
|
||||
radius: pos
|
||||
});
|
||||
|
||||
/*
|
||||
* directly set radius attr to avoid
|
||||
* duplicate attr change event
|
||||
*/
|
||||
this.attrs.radius = go._getXY(radius);
|
||||
}
|
||||
};
|
||||
// extend Shape
|
||||
|
@@ -3127,33 +3127,52 @@ Test.prototype.tests = {
|
||||
height: 50,
|
||||
fill: 'blue',
|
||||
shadow: {
|
||||
offset: [10, 10]
|
||||
offset: [10, 10]
|
||||
}
|
||||
});
|
||||
|
||||
var circle = new Kinetic.Ellipse({
|
||||
x: stage.getWidth() / 2,
|
||||
y: stage.getHeight() / 2,
|
||||
radius: [70, 35],
|
||||
fill: 'green',
|
||||
stroke: 'black',
|
||||
strokeWidth: 4
|
||||
});
|
||||
|
||||
layer.add(circle);
|
||||
layer.add(rect);
|
||||
stage.add(layer);
|
||||
|
||||
var widthChanged = false;
|
||||
var shadowChanged = false;
|
||||
var widthChanged = 0;
|
||||
var shadowChanged = 0;
|
||||
var radiusChanged = 0;
|
||||
|
||||
rect.on('widthChange', function() {
|
||||
widthChanged = true;
|
||||
widthChanged++;
|
||||
});
|
||||
|
||||
|
||||
rect.on('shadowChange', function() {
|
||||
shadowChanged = true;
|
||||
shadowChanged++;
|
||||
});
|
||||
|
||||
circle.on('radiusChange', function() {
|
||||
radiusChanged++;
|
||||
});
|
||||
|
||||
circle.setRadius(70, 20);
|
||||
|
||||
rect.setSize(210);
|
||||
rect.setShadow({
|
||||
offset: {
|
||||
x: 20
|
||||
}
|
||||
offset: {
|
||||
x: 20
|
||||
}
|
||||
});
|
||||
|
||||
test(widthChanged, 'width change event was not fired');
|
||||
test(shadowChanged, 'shadow change event not fired');
|
||||
test(widthChanged === 1, 'width change event was not fired correctly');
|
||||
test(shadowChanged === 1, 'shadow change event not fired correctly');
|
||||
test(radiusChanged === 1, 'radius change event was not fired correctly');
|
||||
|
||||
},
|
||||
'NODE - test setting shadow offset': function(containerId) {
|
||||
var stage = new Kinetic.Stage({
|
||||
|
Reference in New Issue
Block a user