mirror of
https://github.com/konvajs/konva.git
synced 2025-05-03 20:48:00 +08:00
refactored Image event bindings and fixed radial gradient bug
This commit is contained in:
parent
a8c09516ba
commit
3b6dffe6e1
18
dist/kinetic-core.js
vendored
18
dist/kinetic-core.js
vendored
@ -2937,7 +2937,7 @@ Kinetic.Shape.prototype = {
|
|||||||
context.fill();
|
context.fill();
|
||||||
}
|
}
|
||||||
// radial gradient
|
// radial gradient
|
||||||
else if(s.radius && e.radius) {
|
else if((s.radius || s.radius === 0) && (e.radius || e.radius === 0)) {
|
||||||
var context = this.getContext();
|
var context = this.getContext();
|
||||||
var grd = context.createRadialGradient(s.x, s.y, s.radius, e.x, e.y, e.radius);
|
var grd = context.createRadialGradient(s.x, s.y, s.radius, e.x, e.y, e.radius);
|
||||||
var colorStops = fill.colorStops;
|
var colorStops = fill.colorStops;
|
||||||
@ -3479,18 +3479,10 @@ Kinetic.Image = function(config) {
|
|||||||
Kinetic.Rect.apply(this, [config]);
|
Kinetic.Rect.apply(this, [config]);
|
||||||
|
|
||||||
// update attrs when one of the following changes
|
// update attrs when one of the following changes
|
||||||
this.on('widthChange', function() {
|
this.on('widthChange', this._setAttrs);
|
||||||
this._setAttrs();
|
this.on('heightChange', this._setAttrs);
|
||||||
});
|
this.on('imageChange', this._setAttrs);
|
||||||
this.on('heightChange', function() {
|
this.on('cropChange', this._setAttrs);
|
||||||
this._setAttrs();
|
|
||||||
});
|
|
||||||
this.on('imageChange', function() {
|
|
||||||
this._setAttrs();
|
|
||||||
});
|
|
||||||
this.on('cropChange', function() {
|
|
||||||
this._setAttrs();
|
|
||||||
});
|
|
||||||
|
|
||||||
this._setAttrs();
|
this._setAttrs();
|
||||||
};
|
};
|
||||||
|
4
dist/kinetic-core.min.js
vendored
4
dist/kinetic-core.min.js
vendored
File diff suppressed because one or more lines are too long
@ -136,7 +136,7 @@ Kinetic.Shape.prototype = {
|
|||||||
context.fill();
|
context.fill();
|
||||||
}
|
}
|
||||||
// radial gradient
|
// radial gradient
|
||||||
else if(s.radius && e.radius) {
|
else if((s.radius || s.radius === 0) && (e.radius || e.radius === 0)) {
|
||||||
var context = this.getContext();
|
var context = this.getContext();
|
||||||
var grd = context.createRadialGradient(s.x, s.y, s.radius, e.x, e.y, e.radius);
|
var grd = context.createRadialGradient(s.x, s.y, s.radius, e.x, e.y, e.radius);
|
||||||
var colorStops = fill.colorStops;
|
var colorStops = fill.colorStops;
|
||||||
|
@ -14,18 +14,10 @@ Kinetic.Image = function(config) {
|
|||||||
Kinetic.Rect.apply(this, [config]);
|
Kinetic.Rect.apply(this, [config]);
|
||||||
|
|
||||||
// update attrs when one of the following changes
|
// update attrs when one of the following changes
|
||||||
this.on('widthChange', function() {
|
this.on('widthChange', this._setAttrs);
|
||||||
this._setAttrs();
|
this.on('heightChange', this._setAttrs);
|
||||||
});
|
this.on('imageChange', this._setAttrs);
|
||||||
this.on('heightChange', function() {
|
this.on('cropChange', this._setAttrs);
|
||||||
this._setAttrs();
|
|
||||||
});
|
|
||||||
this.on('imageChange', function() {
|
|
||||||
this._setAttrs();
|
|
||||||
});
|
|
||||||
this.on('cropChange', function() {
|
|
||||||
this._setAttrs();
|
|
||||||
});
|
|
||||||
|
|
||||||
this._setAttrs();
|
this._setAttrs();
|
||||||
};
|
};
|
||||||
|
@ -1808,7 +1808,9 @@ Test.prototype.tests = {
|
|||||||
width: 578,
|
width: 578,
|
||||||
height: 200
|
height: 200
|
||||||
});
|
});
|
||||||
var layer = new Kinetic.Layer();
|
var layer = new Kinetic.Layer({
|
||||||
|
throttle: 999
|
||||||
|
});
|
||||||
darth = new Kinetic.Image({
|
darth = new Kinetic.Image({
|
||||||
x: 200,
|
x: 200,
|
||||||
y: 60,
|
y: 60,
|
||||||
@ -1822,6 +1824,12 @@ Test.prototype.tests = {
|
|||||||
|
|
||||||
layer.add(darth);
|
layer.add(darth);
|
||||||
stage.add(layer);
|
stage.add(layer);
|
||||||
|
|
||||||
|
darth.setHeight(200);
|
||||||
|
layer.draw();
|
||||||
|
|
||||||
|
darth.setHeight(100);
|
||||||
|
layer.draw();
|
||||||
|
|
||||||
test(darth.getX() === 200, 'x should be 200');
|
test(darth.getX() === 200, 'x should be 200');
|
||||||
test(darth.getY() === 60, 'y should be 60');
|
test(darth.getY() === 60, 'y should be 60');
|
||||||
|
Loading…
Reference in New Issue
Block a user