mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-08 05:42:07 -05:00
Add dontModify parameter to #set() method in Linked* classes, and rename #_set to #_setter.
This commit is contained in:
parent
a2dc2c7dd8
commit
31be916c4f
3 changed files with 23 additions and 21 deletions
|
@ -438,10 +438,11 @@ var Point = this.Point = Base.extend({
|
||||||
var LinkedPoint = Point.extend({
|
var LinkedPoint = Point.extend({
|
||||||
beans: true,
|
beans: true,
|
||||||
|
|
||||||
set: function(x, y) {
|
set: function(x, y, dontNotify) {
|
||||||
this._x = x;
|
this._x = x;
|
||||||
this._y = y;
|
this._y = y;
|
||||||
this._owner[this._set](this);
|
if (!dontNotify)
|
||||||
|
this._owner[this._setter](this);
|
||||||
return this;
|
return this;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -451,7 +452,7 @@ var LinkedPoint = Point.extend({
|
||||||
|
|
||||||
setX: function(x) {
|
setX: function(x) {
|
||||||
this._x = x;
|
this._x = x;
|
||||||
this._owner[this._set](this);
|
this._owner[this._setter](this);
|
||||||
},
|
},
|
||||||
|
|
||||||
getY: function() {
|
getY: function() {
|
||||||
|
@ -460,16 +461,16 @@ var LinkedPoint = Point.extend({
|
||||||
|
|
||||||
setY: function(y) {
|
setY: function(y) {
|
||||||
this._y = y;
|
this._y = y;
|
||||||
this._owner[this._set](this);
|
this._owner[this._setter](this);
|
||||||
},
|
},
|
||||||
|
|
||||||
statics: {
|
statics: {
|
||||||
create: function(owner, set, x, y) {
|
create: function(owner, setter, x, y) {
|
||||||
var point = new LinkedPoint(LinkedPoint.dont);
|
var point = new LinkedPoint(LinkedPoint.dont);
|
||||||
point._x = x;
|
point._x = x;
|
||||||
point._y = y;
|
point._y = y;
|
||||||
point._owner = owner;
|
point._owner = owner;
|
||||||
point._set = set;
|
point._setter = setter;
|
||||||
return point;
|
return point;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -279,13 +279,13 @@ var Rectangle = this.Rectangle = Base.extend({
|
||||||
var LinkedRectangle = Rectangle.extend({
|
var LinkedRectangle = Rectangle.extend({
|
||||||
beans: true,
|
beans: true,
|
||||||
|
|
||||||
set: function(x, y, width, height) {
|
set: function(x, y, width, height, dontNotify) {
|
||||||
this._x = x;
|
this._x = x;
|
||||||
this._y = y;
|
this._y = y;
|
||||||
this._width = width;
|
this._width = width;
|
||||||
this._height = height;
|
this._height = height;
|
||||||
if (this._owner)
|
if (!dontNotify)
|
||||||
this._owner[this._set](this);
|
this._owner[this._setter](this);
|
||||||
return this;
|
return this;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -295,11 +295,11 @@ var LinkedRectangle = Rectangle.extend({
|
||||||
* does not rely on Point#initialize at all. This speeds up all math
|
* does not rely on Point#initialize at all. This speeds up all math
|
||||||
* operations a lot.
|
* operations a lot.
|
||||||
*/
|
*/
|
||||||
create: function(owner, set, x, y, width, height) {
|
create: function(owner, setter, x, y, width, height) {
|
||||||
var rect = new LinkedRectangle(LinkedRectangle.dont).set(x, y,
|
var rect = new LinkedRectangle(LinkedRectangle.dont).set(
|
||||||
width, height);
|
x, y, width, height, true);
|
||||||
rect._owner = owner;
|
rect._owner = owner;
|
||||||
rect._set = set;
|
rect._setter = setter;
|
||||||
return rect;
|
return rect;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -318,7 +318,7 @@ var LinkedRectangle = Rectangle.extend({
|
||||||
// Check if this setter is called from another one which sets
|
// Check if this setter is called from another one which sets
|
||||||
// _dontNotify, as it will notify itself
|
// _dontNotify, as it will notify itself
|
||||||
if (!this._dontNotify)
|
if (!this._dontNotify)
|
||||||
this._owner[this._set](this);
|
this._owner[this._setter](this);
|
||||||
};
|
};
|
||||||
}, Base.each(['Point', 'Size', 'Center',
|
}, Base.each(['Point', 'Size', 'Center',
|
||||||
'Left', 'Top', 'Right', 'Bottom', 'CenterX', 'CenterY',
|
'Left', 'Top', 'Right', 'Bottom', 'CenterX', 'CenterY',
|
||||||
|
@ -333,7 +333,7 @@ var LinkedRectangle = Rectangle.extend({
|
||||||
this._dontNotify = true;
|
this._dontNotify = true;
|
||||||
proto[name].apply(this, arguments);
|
proto[name].apply(this, arguments);
|
||||||
delete this._dontNotify;
|
delete this._dontNotify;
|
||||||
this._owner[this._set](this);
|
this._owner[this._setter](this);
|
||||||
return this;
|
return this;
|
||||||
};
|
};
|
||||||
}, { beans: true })
|
}, { beans: true })
|
||||||
|
|
|
@ -140,10 +140,11 @@ var Size = this.Size = Base.extend({
|
||||||
var LinkedSize = Size.extend({
|
var LinkedSize = Size.extend({
|
||||||
beans: true,
|
beans: true,
|
||||||
|
|
||||||
set: function(width, height) {
|
set: function(width, height, dontNotify) {
|
||||||
this._width = width;
|
this._width = width;
|
||||||
this._height = height;
|
this._height = height;
|
||||||
this._owner[this._set](this);
|
if (!dontNotify)
|
||||||
|
this._owner[this._setter](this);
|
||||||
return this;
|
return this;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -153,7 +154,7 @@ var LinkedSize = Size.extend({
|
||||||
|
|
||||||
setWidth: function(width) {
|
setWidth: function(width) {
|
||||||
this._width = width;
|
this._width = width;
|
||||||
this._owner[this._set](this);
|
this._owner[this._setter](this);
|
||||||
},
|
},
|
||||||
|
|
||||||
getHeight: function() {
|
getHeight: function() {
|
||||||
|
@ -162,16 +163,16 @@ var LinkedSize = Size.extend({
|
||||||
|
|
||||||
setHeight: function(height) {
|
setHeight: function(height) {
|
||||||
this._height = height;
|
this._height = height;
|
||||||
this._owner[this._set](this);
|
this._owner[this._setter](this);
|
||||||
},
|
},
|
||||||
|
|
||||||
statics: {
|
statics: {
|
||||||
create: function(owner, set, width, height) {
|
create: function(owner, setter, width, height) {
|
||||||
var point = new LinkedSize(LinkedSize.dont);
|
var point = new LinkedSize(LinkedSize.dont);
|
||||||
point._width = width;
|
point._width = width;
|
||||||
point._height = height;
|
point._height = height;
|
||||||
point._owner = owner;
|
point._owner = owner;
|
||||||
point._set = set;
|
point._setter = setter;
|
||||||
return point;
|
return point;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue