mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-01 02:38:43 -05:00
Merge remote branch 'origin/master'
Conflicts: test/lib/helpers.js
This commit is contained in:
commit
0a86c2b34e
5 changed files with 16 additions and 12 deletions
|
@ -36,9 +36,8 @@ var Item = this.Item = Base.extend({
|
|||
},
|
||||
|
||||
_clone: function(copy) {
|
||||
// If this item has a pathStyle, copy it:
|
||||
if (this._style)
|
||||
copy.setStyle(this._style);
|
||||
// Copy over style
|
||||
copy.setStyle(this._style);
|
||||
// If this item has children, clone and append each of them:
|
||||
if (this._children) {
|
||||
for (var i = 0, l = this._children.length; i < l; i++)
|
||||
|
|
|
@ -63,7 +63,7 @@ var PathStyle = this.PathStyle = Base.extend(new function() {
|
|||
} else {
|
||||
var old = this['_' + key];
|
||||
if (old != value && !(old && old.equals && old.equals(value))) {
|
||||
this['_' + key] = value;
|
||||
this['_' + key] = value && value.clone ? value.clone() : value;
|
||||
if (this._item) {
|
||||
this._item._changed(ChangeFlags.STYLE
|
||||
| (strokeFlags[key] ? ChangeFlags.STROKE : 0));
|
||||
|
@ -83,7 +83,8 @@ var PathStyle = this.PathStyle = Base.extend(new function() {
|
|||
var childStyle = children[i]._style[get]();
|
||||
if (!style) {
|
||||
style = childStyle;
|
||||
} else if (style != childStyle) {
|
||||
} else if (style != childStyle && !(style && style.equals
|
||||
&& style.equals(childStyle))) {
|
||||
// If there is another item with a different style,
|
||||
// the style is not defined:
|
||||
// PORT: Change this in Sg (currently returns null)
|
||||
|
@ -96,6 +97,7 @@ var PathStyle = this.PathStyle = Base.extend(new function() {
|
|||
}
|
||||
};
|
||||
|
||||
// Style-getters and setters for Item:
|
||||
// 'this' = the Base.each() side-car = the object that is returned from
|
||||
// Base.each and injected into Item above:
|
||||
this[set] = function(value) {
|
||||
|
|
|
@ -55,17 +55,20 @@ var SegmentPoint = Point.extend({
|
|||
},
|
||||
|
||||
statics: {
|
||||
create: function(segment, x, y) {
|
||||
create: function(segment, x, y, selected) {
|
||||
if (y === undefined) {
|
||||
// Use the normal point constructor to read in point values
|
||||
var tmp = new Point(x);
|
||||
x = tmp.x;
|
||||
y = tmp.y;
|
||||
var pt = x instanceof Point ? x : new Point(x);
|
||||
x = pt.x;
|
||||
y = pt.y;
|
||||
selected = pt.selected;
|
||||
}
|
||||
var point = new SegmentPoint(SegmentPoint.dont);
|
||||
point._x = x;
|
||||
point._y = y;
|
||||
point._owner = segment;
|
||||
if (selected)
|
||||
point.setSelected(true);
|
||||
return point;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,7 +17,7 @@ test('Path#clone()', function() {
|
|||
path.locked = true;
|
||||
path.visible = false;
|
||||
path.blendMode = 'blend';
|
||||
path._clipMask = true;
|
||||
path.clipMask = true;
|
||||
path.selected = true;
|
||||
cloneAndCompare(path);
|
||||
});
|
||||
|
|
|
@ -95,7 +95,7 @@ test('appendTop / appendBottom / nesting', function() {
|
|||
return project.layers.length;
|
||||
}, 2);
|
||||
equals(function() {
|
||||
return project.layers[0] == firstLayer
|
||||
&& project.layers[1] == secondLayer;
|
||||
return project.layers[0] == secondLayer
|
||||
&& project.layers[1] == firstLayer;
|
||||
}, true);
|
||||
});
|
Loading…
Reference in a new issue