actuate
Version:
Actuate is a flexible, fast "tween" library for animations
107 lines (89 loc) • 3.4 kB
JavaScript
// Class: motion.actuators.MethodActuator
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;
var $import = require("./../../import_stub").default;
var $extend = require("./../../extend_stub").default;
function motion_actuators_SimpleActuator() {return require("./../../motion/actuators/SimpleActuator");}
function Reflect() {return require("./../../Reflect");}
function motion_actuators_PropertyDetails() {return require("./../../motion/actuators/PropertyDetails");}
// Constructor
var MethodActuator = function(target,duration,properties) {
this.currentParameters = [];
this.tweenProperties = { };
(motion_actuators_SimpleActuator().default).call(this,target,duration,properties);
if(!(Reflect().default).hasField(properties,"start")) {
this.properties.start = [];
}
if(!(Reflect().default).hasField(properties,"end")) {
this.properties.end = this.properties.start;
}
var _g1 = 0;
var _g = this.properties.start.length;
while(_g1 < _g) {
var i = _g1++;
this.currentParameters.push(this.properties.start[i]);
}
}
// Meta
MethodActuator.__name__ = ["motion","actuators","MethodActuator"];
MethodActuator.__isInterface__ = false;
MethodActuator.__super__ = (motion_actuators_SimpleActuator().default);
MethodActuator.prototype = $extend((motion_actuators_SimpleActuator().default).prototype, {
apply: function() {
this.callMethod(this.target,this.properties.end);
},
complete: function(sendEvent) {
if(sendEvent == null) {
sendEvent = true;
}
if(this.initialized) {
var _g1 = 0;
var _g = this.properties.start.length;
while(_g1 < _g) {
var i = _g1++;
this.currentParameters[i] = (Reflect().default).field(this.tweenProperties,"param" + i);
}
this.callMethod(this.target,this.currentParameters);
}
(motion_actuators_SimpleActuator().default).prototype.complete.call(this,sendEvent);
},
initialize: function() {
var details;
var propertyName;
var start;
var _g1 = 0;
var _g = this.properties.start.length;
while(_g1 < _g) {
var i = _g1++;
propertyName = "param" + i;
start = this.properties.start[i];
(Reflect().default).setField(this.tweenProperties,propertyName,start);
if(typeof(start) == "number" || typeof(start) == "number" && ((start | 0) === start)) {
details = new (motion_actuators_PropertyDetails().default)(this.tweenProperties,propertyName,start,this.properties.end[i] - start);
this.propertyDetails.push(details);
}
}
this.detailsLength = this.propertyDetails.length;
this.initialized = true;
},
update: function(currentTime) {
(motion_actuators_SimpleActuator().default).prototype.update.call(this,currentTime);
if(this.active && !this.paused) {
var _g1 = 0;
var _g = this.properties.start.length;
while(_g1 < _g) {
var i = _g1++;
this.currentParameters[i] = (Reflect().default).field(this.tweenProperties,"param" + i);
}
this.callMethod(this.target,this.currentParameters);
}
}
});
MethodActuator.prototype.__class__ = MethodActuator.prototype.constructor = $hxClasses["motion.actuators.MethodActuator"] = MethodActuator;
// Init
// Statics
// Export
exports.default = MethodActuator;