actuate
Version:
Actuate is a flexible, fast "tween" library for animations
89 lines (71 loc) • 1.97 kB
JavaScript
// Class: motion._MotionPath.ComponentPath
var $global = typeof window != "undefined" ? window : typeof global != "undefined" ? global : typeof self != "undefined" ? self : this
$global.Object.defineProperty(exports, "__esModule", {value: true});
var __map_reserved = {};
// Imports
var $hxClasses = require("./../../hxClasses_stub").default;
function motion_IComponentPath() {return require("./../../motion/IComponentPath");}
// Constructor
var ComponentPath = function() {
this.paths = [];
this.strength = 0;
}
// Meta
ComponentPath.__name__ = ["motion","_MotionPath","ComponentPath"];
ComponentPath.__isInterface__ = false;
ComponentPath.__interfaces__ = [(motion_IComponentPath().default)];
ComponentPath.prototype = {
addPath: function(path) {
if(this.paths.length > 0) {
path.set_start(this.paths[this.paths.length - 1].get_end());
}
this.paths.push(path);
this.strength += path.strength;
},
calculate: function(k) {
if(this.paths.length == 1) {
return this.paths[0].calculate(k);
} else {
var ratio = k * this.strength;
var _g = 0;
var _g1 = this.paths;
while(_g < _g1.length) {
var path = _g1[_g];
++_g;
if(ratio - path.strength > 1e-7) {
ratio -= path.strength;
} else {
return path.calculate(ratio / path.strength);
}
}
}
return 0;
},
get_start: function() {
if(this.paths.length > 0) {
return this.paths[0].get_start();
} else {
return 0;
}
},
set_start: function(value) {
if(this.paths.length > 0) {
return this.paths[0].set_start(value);
} else {
return 0;
}
},
get_end: function() {
if(this.paths.length > 0) {
var path = this.paths[this.paths.length - 1];
return path.get_end();
} else {
return this.get_start();
}
}
};
ComponentPath.prototype.__class__ = ComponentPath.prototype.constructor = $hxClasses["motion._MotionPath.ComponentPath"] = ComponentPath;
// Init
// Statics
// Export
exports.default = ComponentPath;