mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-03-13 16:33:28 -04:00
Remove all left-overs of call chaining, except for where it's in use.
This commit is contained in:
parent
0e72dbd2e0
commit
1d1e6425fa
9 changed files with 27 additions and 40 deletions
|
@ -182,7 +182,6 @@ var Rectangle = this.Rectangle = Base.extend(/** @lends Rectangle# */{
|
|||
point = Point.read(arguments);
|
||||
this.x = point.x;
|
||||
this.y = point.y;
|
||||
return this;
|
||||
},
|
||||
|
||||
|
||||
|
@ -201,7 +200,6 @@ var Rectangle = this.Rectangle = Base.extend(/** @lends Rectangle# */{
|
|||
size = Size.read(arguments);
|
||||
this.width = size.width;
|
||||
this.height = size.height;
|
||||
return this;
|
||||
},
|
||||
|
||||
/**
|
||||
|
@ -220,7 +218,6 @@ var Rectangle = this.Rectangle = Base.extend(/** @lends Rectangle# */{
|
|||
setLeft: function(left) {
|
||||
this.width -= left - this.x;
|
||||
this.x = left;
|
||||
return this;
|
||||
},
|
||||
|
||||
/**
|
||||
|
@ -237,7 +234,6 @@ var Rectangle = this.Rectangle = Base.extend(/** @lends Rectangle# */{
|
|||
setTop: function(top) {
|
||||
this.height -= top - this.y;
|
||||
this.y = top;
|
||||
return this;
|
||||
},
|
||||
|
||||
/**
|
||||
|
@ -253,7 +249,6 @@ var Rectangle = this.Rectangle = Base.extend(/** @lends Rectangle# */{
|
|||
|
||||
setRight: function(right) {
|
||||
this.width = right - this.x;
|
||||
return this;
|
||||
},
|
||||
|
||||
/**
|
||||
|
@ -269,7 +264,6 @@ var Rectangle = this.Rectangle = Base.extend(/** @lends Rectangle# */{
|
|||
|
||||
setBottom: function(bottom) {
|
||||
this.height = bottom - this.y;
|
||||
return this;
|
||||
},
|
||||
|
||||
/**
|
||||
|
@ -285,7 +279,6 @@ var Rectangle = this.Rectangle = Base.extend(/** @lends Rectangle# */{
|
|||
|
||||
setCenterX: function(x) {
|
||||
this.x = x - this.width * 0.5;
|
||||
return this;
|
||||
},
|
||||
|
||||
/**
|
||||
|
@ -301,7 +294,6 @@ var Rectangle = this.Rectangle = Base.extend(/** @lends Rectangle# */{
|
|||
|
||||
setCenterY: function(y) {
|
||||
this.y = y - this.height * 0.5;
|
||||
return this;
|
||||
},
|
||||
|
||||
/**
|
||||
|
@ -319,7 +311,11 @@ var Rectangle = this.Rectangle = Base.extend(/** @lends Rectangle# */{
|
|||
|
||||
setCenter: function(point) {
|
||||
point = Point.read(arguments);
|
||||
return this.setCenterX(point.x).setCenterY(point.y);
|
||||
this.setCenterX(point.x);
|
||||
this.setCenterY(point.y);
|
||||
// A special setter where we allow chaining, because it comes in handy
|
||||
// in a couple of places in core.
|
||||
return this;
|
||||
},
|
||||
|
||||
/**
|
||||
|
@ -736,8 +732,8 @@ var Rectangle = this.Rectangle = Base.extend(/** @lends Rectangle# */{
|
|||
};
|
||||
this[set] = function(point) {
|
||||
point = Point.read(arguments);
|
||||
// Note: call chaining happens here.
|
||||
return this[setX](point.x)[setY](point.y);
|
||||
this[setX](point.x);
|
||||
this[setY](point.y);
|
||||
};
|
||||
}, {});
|
||||
});
|
||||
|
@ -810,7 +806,6 @@ var LinkedRectangle = Rectangle.extend({
|
|||
proto[name].apply(this, arguments);
|
||||
delete this._dontNotify;
|
||||
this._owner[this._setter](this);
|
||||
return this;
|
||||
};
|
||||
}, {
|
||||
/**
|
||||
|
|
|
@ -337,7 +337,6 @@ var Color = this.Color = Base.extend(new function() {
|
|||
// All other values are 0..1
|
||||
: Math.min(Math.max(value, 0), 1);
|
||||
this._changed();
|
||||
return this;
|
||||
};
|
||||
}, src);
|
||||
}
|
||||
|
@ -434,7 +433,6 @@ var Color = this.Color = Base.extend(new function() {
|
|||
setAlpha: function(alpha) {
|
||||
this._alpha = alpha == null ? null : Math.min(Math.max(alpha, 0), 1);
|
||||
this._changed();
|
||||
return this;
|
||||
},
|
||||
|
||||
/**
|
||||
|
|
|
@ -107,7 +107,6 @@ var Gradient = this.Gradient = Base.extend(/** @lends Gradient# */{
|
|||
stop.setRampPoint(i / (l - 1));
|
||||
}
|
||||
this._changed();
|
||||
return this;
|
||||
},
|
||||
|
||||
/**
|
||||
|
|
|
@ -147,7 +147,6 @@ var GradientColor = this.GradientColor = Color.extend(/** @lends GradientColor#
|
|||
if (this._destination)
|
||||
this._radius = this._destination.getDistance(this._origin);
|
||||
this._changed();
|
||||
return this;
|
||||
},
|
||||
|
||||
/**
|
||||
|
@ -189,7 +188,6 @@ var GradientColor = this.GradientColor = Color.extend(/** @lends GradientColor#
|
|||
this._destination = destination;
|
||||
this._radius = this._destination.getDistance(this._origin);
|
||||
this._changed();
|
||||
return this;
|
||||
},
|
||||
|
||||
/**
|
||||
|
@ -234,7 +232,6 @@ var GradientColor = this.GradientColor = Color.extend(/** @lends GradientColor#
|
|||
this._hilite = hilite;
|
||||
}
|
||||
this._changed();
|
||||
return this;
|
||||
},
|
||||
|
||||
toCanvasStyle: function(ctx) {
|
||||
|
|
|
@ -18,31 +18,32 @@ var Callback = {
|
|||
attach: function(type, func) {
|
||||
// If an object literal is passed, attach all callbacks defined in it
|
||||
if (typeof type !== 'string') {
|
||||
return Base.each(type, function(value, key) {
|
||||
Base.each(type, function(value, key) {
|
||||
this.attach(key, value);
|
||||
}, this);
|
||||
return;
|
||||
}
|
||||
var entry = this._eventTypes[type];
|
||||
if (!entry)
|
||||
return this;
|
||||
var handlers = this._handlers = this._handlers || {};
|
||||
handlers = handlers[type] = handlers[type] || [];
|
||||
if (handlers.indexOf(func) == -1) { // Not added yet, add it now
|
||||
handlers.push(func);
|
||||
// See if this is the first handler that we're attaching, and
|
||||
// call install if defined.
|
||||
if (entry.install && handlers.length == 1)
|
||||
entry.install.call(this, type);
|
||||
if (entry) {
|
||||
var handlers = this._handlers = this._handlers || {};
|
||||
handlers = handlers[type] = handlers[type] || [];
|
||||
if (handlers.indexOf(func) == -1) { // Not added yet, add it now
|
||||
handlers.push(func);
|
||||
// See if this is the first handler that we're attaching, and
|
||||
// call install if defined.
|
||||
if (entry.install && handlers.length == 1)
|
||||
entry.install.call(this, type);
|
||||
}
|
||||
}
|
||||
return this;
|
||||
},
|
||||
|
||||
detach: function(type, func) {
|
||||
// If an object literal is passed, detach all callbacks defined in it
|
||||
if (typeof type !== 'string') {
|
||||
return Base.each(type, function(value, key) {
|
||||
Base.each(type, function(value, key) {
|
||||
this.detach(key, value);
|
||||
}, this);
|
||||
return;
|
||||
}
|
||||
var entry = this._eventTypes[type],
|
||||
handlers = this._handlers && this._handlers[type],
|
||||
|
@ -60,7 +61,6 @@ var Callback = {
|
|||
handlers.splice(index, 1);
|
||||
}
|
||||
}
|
||||
return this;
|
||||
},
|
||||
|
||||
fire: function(type, event) {
|
||||
|
|
|
@ -116,7 +116,6 @@ var Group = this.Group = Item.extend(/** @lends Group# */{
|
|||
var child = this.getFirstChild();
|
||||
if (child)
|
||||
child.setClipMask(clipped);
|
||||
return this;
|
||||
},
|
||||
|
||||
draw: function(ctx, param) {
|
||||
|
|
|
@ -2089,6 +2089,7 @@ var Item = this.Item = Base.extend(Callback, {
|
|||
// Transform position as well.
|
||||
this._position = matrix._transformPoint(position, position);
|
||||
}
|
||||
// Allow chaining here, since transform() is related to Matrix functions
|
||||
return this;
|
||||
},
|
||||
|
||||
|
|
|
@ -118,13 +118,12 @@ var Style = Base.extend({
|
|||
return style;
|
||||
};
|
||||
// Style-getters and setters for owner class:
|
||||
owner[set] = function(value) {
|
||||
this[styleKey][set](value);
|
||||
return this;
|
||||
};
|
||||
owner[get] = function() {
|
||||
return this[styleKey][get]();
|
||||
};
|
||||
owner[set] = function(value) {
|
||||
this[styleKey][set](value);
|
||||
};
|
||||
});
|
||||
src._owner.inject(owner);
|
||||
// Pass on to base()
|
||||
|
|
|
@ -22,17 +22,16 @@ var Event = this.Event = Base.extend(/** @lends Event# */{
|
|||
preventDefault: function() {
|
||||
this._prevented = true;
|
||||
DomEvent.preventDefault(this.event);
|
||||
return this;
|
||||
},
|
||||
|
||||
stopPropagation: function() {
|
||||
this._stopped = true;
|
||||
DomEvent.stopPropagation(this.event);
|
||||
return this;
|
||||
},
|
||||
|
||||
stop: function() {
|
||||
return this.stopPropagation().preventDefault();
|
||||
this.stopPropagation();
|
||||
this.preventDefault();
|
||||
},
|
||||
|
||||
// DOCS: Document Event#modifiers
|
||||
|
|
Loading…
Reference in a new issue