-
-
Notifications
You must be signed in to change notification settings - Fork 3.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Single API for animating colors and other properties #6191
Changes from all commits
bd900b2
9dc11ca
664152f
cdd5a82
3064455
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -596,6 +596,14 @@ | |
' strokeLineCap strokeDashOffset strokeLineJoin strokeMiterLimit backgroundColor clipPath' | ||
).split(' '), | ||
|
||
/** | ||
* List of properties to consider for animating colors. | ||
* @type Array | ||
*/ | ||
colorProperties: ( | ||
'fill stroke backgroundColor' | ||
).split(' '), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. i want to merge this as it is, but i think i will come back and move There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I see, the reason I put it on the object class is because I thought it might be easier to create a new shape class with a custom property name that involved coloring but as you like :) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. i know but so many options. |
||
|
||
/** | ||
* a fabricObject that, without stroke define a clipping area with their shape. filled in black | ||
* the clipPath object gets used when the object has rendered, and the context is placed in the center | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -65,6 +65,24 @@ | |
}, 1000); | ||
}); | ||
|
||
QUnit.test('animate with color', function(assert) { | ||
var done = assert.async(), properties = fabric.Object.prototype.colorProperties, | ||
object = new fabric.Object(); | ||
|
||
properties.forEach(function (prop, index) { | ||
object.set(prop, 'red'); | ||
object.animate(prop, 'blue'); | ||
assert.ok(true, 'animate without options does not crash'); | ||
|
||
setTimeout(function () { | ||
assert.equal(object[prop], new fabric.Color('blue').toRgba(), 'property [' + prop + '] has been animated'); | ||
if (index === properties.length - 1) { | ||
done(); | ||
} | ||
}, 1000); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can we use the animation callback instead of a timeout? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. sure, i was just copying the other tests but i can do that! you mean in a onComplete callback? |
||
}); | ||
}); | ||
|
||
QUnit.test('animate with decrement', function(assert) { | ||
var done = assert.async(); | ||
var object = new fabric.Object({ left: 20, top: 30, width: 40, height: 50, angle: 43 }); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is
borderColor
something we should consider animatable? if yes, why not also cornerColor, cornerStrokeColor and all the rest?I would leave borderColor out for now. But of course if you think is really important, argument why.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i personally wouldn't use either, it was just for testing so I think we can leave it out for now