mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2024-12-29 09:22:22 -05:00
Document tween update event as Tween#onUpdate
.
This commit is contained in:
parent
6d411e9b7f
commit
a97382d1c5
2 changed files with 23 additions and 24 deletions
|
@ -4694,8 +4694,8 @@ new function() { // Injection scope for hit-test functions shared with project
|
|||
* var path = new Path.Circle({
|
||||
* radius: view.bounds.height * 0.4,
|
||||
* center: view.center
|
||||
* })
|
||||
* path.tween({ fillColor: 'blue' }, { fillColor: 'red' }, 3000)
|
||||
* });
|
||||
* path.tween({ fillColor: 'blue' }, { fillColor: 'red' }, 3000);
|
||||
*/
|
||||
/**
|
||||
* Tween item to a state.
|
||||
|
@ -4713,14 +4713,14 @@ new function() { // Injection scope for hit-test functions shared with project
|
|||
* size: [100, 100],
|
||||
* position: view.center,
|
||||
* fillColor: 'red',
|
||||
* })
|
||||
* });
|
||||
*
|
||||
* var delta = { x: path.bounds.width / 2, y: 0 }
|
||||
* var delta = { x: path.bounds.width / 2, y: 0 };
|
||||
*
|
||||
* path.tween({
|
||||
* 'segments[1].point': ['+=', delta],
|
||||
* 'segments[2].point.x': '-= 50'
|
||||
* }, 3000)
|
||||
* }, 3000);
|
||||
*
|
||||
* @see Item#tween(from, to, options)
|
||||
*/
|
||||
|
@ -4741,16 +4741,16 @@ new function() { // Injection scope for hit-test functions shared with project
|
|||
* fillColor: 'blue',
|
||||
* radius: view.bounds.height * 0.4,
|
||||
* center: view.center,
|
||||
* })
|
||||
* });
|
||||
* var pathFrom = path.clone({ insert: false })
|
||||
* var pathTo = new Path.Rectangle({
|
||||
* position: view.center,
|
||||
* rectangle: path.bounds,
|
||||
* insert: false
|
||||
* })
|
||||
* path.tween(2000).on('update', function(event) {
|
||||
* });
|
||||
* path.tween(2000).onUpdate = function(event) {
|
||||
* path.interpolate(pathFrom, pathTo, event.factor)
|
||||
* })
|
||||
* };
|
||||
*/
|
||||
tween: function(from, to, options) {
|
||||
if (!options) {
|
||||
|
@ -4814,8 +4814,8 @@ new function() { // Injection scope for hit-test functions shared with project
|
|||
* fillColor: 'blue',
|
||||
* radius: view.bounds.height * 0.4,
|
||||
* center: view.center
|
||||
* })
|
||||
* path.tweenFrom({ fillColor: 'red' }, { duration: 1000 })
|
||||
* });
|
||||
* path.tweenFrom({ fillColor: 'red' }, { duration: 1000 });
|
||||
*/
|
||||
tweenFrom: function(state, options) {
|
||||
return this.tween(state, null, options);
|
||||
|
|
|
@ -257,19 +257,15 @@ var Tween = Base.extend(Emitter, /** @lends Tween# */{
|
|||
},
|
||||
|
||||
/**
|
||||
* {@grouptitle Event Handling}
|
||||
* {@grouptitle Event Handlers}
|
||||
*
|
||||
* Attaches an event handler to the tween.
|
||||
*
|
||||
* @name Tween#on
|
||||
* @function
|
||||
* @param {String} type the type of event (currently only 'update')
|
||||
* @param {Function} function the function to be called when the event
|
||||
* occurs, receiving an object as its
|
||||
* sole argument, containing the current progress of the
|
||||
* tweening and the factor calculated by the easing function
|
||||
* @return {Tween} this tween itself, so calls can be chained
|
||||
* The function to be called when the tween is updated. It receives an
|
||||
* object as its sole argument, containing the current progress of the
|
||||
* tweening and the factor calculated by the easing function.
|
||||
*
|
||||
* @name Tween#onUpdate
|
||||
* @property
|
||||
* @type Function
|
||||
*
|
||||
* @example {@paperscript}
|
||||
* // Display tween progression values:
|
||||
|
@ -284,11 +280,14 @@ var Tween = Base.extend(Emitter, /** @lends Tween# */{
|
|||
* );
|
||||
* var progressText = new PointText(view.center + [60, -10]);
|
||||
* var factorText = new PointText(view.center + [60, 10]);
|
||||
* tween.on('update', function(event) {
|
||||
* tween.onUpdate = function(event) {
|
||||
* progressText.content = 'progress: ' + event.progress.toFixed(2);
|
||||
* factorText.content = 'factor: ' + event.factor.toFixed(2);
|
||||
* });
|
||||
* };
|
||||
*/
|
||||
_events: {
|
||||
onUpdate: {}
|
||||
},
|
||||
|
||||
_getState: function(state) {
|
||||
var keys = this._keys,
|
||||
|
|
Loading…
Reference in a new issue