forked from Jibo-Revival-Group/JiboOs
212 lines
4.9 KiB
JavaScript
212 lines
4.9 KiB
JavaScript
/**
|
|
* Abstract Tween base object.
|
|
* Uses `ease npm` for all ease functions.
|
|
* For ease types, refer to [ease APIs]{@link https://www.npmjs.com/package/eases}.
|
|
* @class Tween
|
|
* @memberof jibo.face
|
|
*/
|
|
|
|
/**
|
|
* `true` if the tween is to be paused.
|
|
* @name jibo.face.Tween#paused
|
|
* @type {Boolean}
|
|
*/
|
|
|
|
/**
|
|
* The local lerp value for just this tween.
|
|
* @name jibo.face.Tween#_time
|
|
* @type {Number}
|
|
* @protected
|
|
*/
|
|
|
|
/**
|
|
* Duration in milliseconds.
|
|
* @name jibo.face.Tween#_duration
|
|
* @type {Number}
|
|
* @protected
|
|
*/
|
|
|
|
/**
|
|
* Finished callback
|
|
* @name jibo.face.Tween#_complete
|
|
* @type {Function}
|
|
* @private
|
|
*/
|
|
|
|
/**
|
|
* Flag used to block tween from being manually stopped.
|
|
* @name jibo.face.Tween#_inProcess
|
|
* @type {Boolean}
|
|
* @private
|
|
*/
|
|
|
|
/**
|
|
* the number of milliseconds to delay this tween from playing from the time it was added to the TweenMgr
|
|
* @name jibo.face.Tween#_delay
|
|
* @type {Number}
|
|
* @private
|
|
*/
|
|
|
|
/**
|
|
* Elapsed time in milliseconds
|
|
* @name jibo.face.Tween#_elapsed
|
|
* @type {Number}
|
|
* @private
|
|
*/
|
|
|
|
/**
|
|
* Starting value
|
|
* @name jibo.face.Tween#_start
|
|
* @type {Object}
|
|
* @private
|
|
*/
|
|
|
|
/**
|
|
* Ending value
|
|
* @name jibo.face.Tween#_end
|
|
* @type {Object}
|
|
* @private
|
|
*/
|
|
|
|
/**
|
|
* Ease callback.
|
|
* @name jibo.face.Tween#_ease
|
|
* @type {Function}
|
|
* @private
|
|
*/
|
|
|
|
/**
|
|
* Target for tweening.
|
|
* @name jibo.face.Tween#_target
|
|
* @type {Object}
|
|
* @private
|
|
*/
|
|
|
|
/**
|
|
* Initial the tween.
|
|
* @method jibo.face.Tween#init
|
|
* @param {*} [target] The thing to tween.
|
|
* @param {Object} options Options for tweening.
|
|
* @param {Object} [options.to] The values to tween the object to.
|
|
* @param {Object} [options.from] The initial values to set the object to.
|
|
* @param {String} [options.ease='linear'] The ease function to use.
|
|
* @param {int} [options.delay=0] The delay to start.
|
|
* @param {int} [options.duration=500] Length of tween, in millseconds.
|
|
* @param {Function} [complete] Callback function, if any.
|
|
*/
|
|
|
|
/**
|
|
* Update the tween value.
|
|
* @method jibo.face.Tween#reset
|
|
* @param {Number} v0 start number
|
|
* @param {Number} v1 end number
|
|
* @param {Number} t Time
|
|
* @private
|
|
*/
|
|
|
|
/**
|
|
* The delay of start of tween in milliseconds.
|
|
* @name jibo.face.Tween#delay
|
|
* @type {Number}
|
|
*/
|
|
|
|
/**
|
|
* The duration of this tween.
|
|
* @name jibo.face.Tween#duration
|
|
* @type {Number}
|
|
* @readOnly
|
|
*/
|
|
|
|
/**
|
|
* The current time from 0 to 1.
|
|
* @name jibo.face.Tween#time
|
|
* @type {Number}
|
|
* @readOnly
|
|
*/
|
|
|
|
/**
|
|
* The target to tween.
|
|
* @name jibo.face.Tween#target
|
|
* @type {any}
|
|
* @readOnly
|
|
*/
|
|
|
|
/**
|
|
* Flag indicating if tween is in a process that should not be manually stopped.
|
|
* @name jibo.face.Tween#inProcess
|
|
* @type {Boolean}
|
|
* @readOnly
|
|
*/
|
|
|
|
/**
|
|
* Call the finished callback.
|
|
* @method jibo.face.Tween#completed
|
|
*/
|
|
|
|
/**
|
|
* Event when tween is completed.
|
|
* @event jibo.face.Tween#complete
|
|
* @param {*} target The target of tween.
|
|
*/
|
|
|
|
/**
|
|
* Update the tween value.
|
|
* @method jibo.face.Tween#update
|
|
* @param {Number} elapsed Milliseconds since the last update.
|
|
*/
|
|
|
|
/**
|
|
* Event when tween value has changed.
|
|
* @event jibo.face.Tween#change
|
|
* @param {*} value The value or values set.
|
|
* @param {*} target The target of tween.
|
|
*/
|
|
|
|
/**
|
|
* Assign a collection of properties.
|
|
* @method jibo.face.Tween#assign
|
|
* @param {Object} values Map of properties to set
|
|
* @private
|
|
*/
|
|
|
|
/**
|
|
* Assign a specific property and value to the target.
|
|
* @method jibo.face.Tween#assignValue
|
|
* @param {String} prop Property name.
|
|
* @param {Number|String} value Value to set.
|
|
* @private
|
|
*/
|
|
|
|
/**
|
|
* Update the tween value.
|
|
* @method jibo.face.Tween#lerp
|
|
* @param {Number} v0 start number
|
|
* @param {Number} v1 end number
|
|
* @param {Number} t Time
|
|
* @private
|
|
*/
|
|
|
|
/**
|
|
* Auto-generate the start key values.
|
|
* @method jibo.face.Tween#startDefaults
|
|
* @param {Object} to end keys
|
|
* @private
|
|
* @return {Object} Default start keys
|
|
*/
|
|
|
|
/**
|
|
* Auto-generate the end key values.
|
|
* @method jibo.face.Tween#endDefaults
|
|
* @param {Object} from start keys
|
|
* @private
|
|
* @return {Object} Default end keys
|
|
*/
|
|
|
|
/**
|
|
* Check that both objects have the same keys.
|
|
* @method jibo.face.Tween#validate
|
|
* @private
|
|
* @param {Object|Number} obj1 Object 1 to compare
|
|
* @param {Object|Number} obj2 Object 2 to compare
|
|
* @return {Boolean} `true` if both have the same keys.
|
|
*/ |