UNPKG

animated

Version:

Declarative Animations Library for React and React Native

59 lines (37 loc) 2.62 kB
'use strict';var _createClass=function(){function defineProperties(target,props){for(var i=0;i<props.length;i++){var descriptor=props[i];descriptor.enumerable=descriptor.enumerable||false;descriptor.configurable=true;if("value"in descriptor)descriptor.writable=true;Object.defineProperty(target,descriptor.key,descriptor);}}return function(Constructor,protoProps,staticProps){if(protoProps)defineProperties(Constructor.prototype,protoProps);if(staticProps)defineProperties(Constructor,staticProps);return Constructor;};}();function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor)){throw new TypeError("Cannot call a class as a function");}}function _possibleConstructorReturn(self,call){if(!self){throw new ReferenceError("this hasn't been initialised - super() hasn't been called");}return call&&(typeof call==="object"||typeof call==="function")?call:self;}function _inherits(subClass,superClass){if(typeof superClass!=="function"&&superClass!==null){throw new TypeError("Super expression must either be null or a function, not "+typeof superClass);}subClass.prototype=Object.create(superClass&&superClass.prototype,{constructor:{value:subClass,enumerable:false,writable:true,configurable:true}});if(superClass)Object.setPrototypeOf?Object.setPrototypeOf(subClass,superClass):subClass.__proto__=superClass;} var Animated=require('./Animated'); var AnimatedWithChildren=require('./AnimatedWithChildren');var AnimatedTemplate=function(_AnimatedWithChildren){_inherits(AnimatedTemplate,_AnimatedWithChildren); function AnimatedTemplate(strings,values){_classCallCheck(this,AnimatedTemplate);var _this=_possibleConstructorReturn(this,(AnimatedTemplate.__proto__||Object.getPrototypeOf(AnimatedTemplate)).call(this)); _this._strings=strings; _this._values=values;return _this; }_createClass(AnimatedTemplate,[{key:'__transformValue',value:function __transformValue( value){ if(value instanceof Animated){ return value.__getValue(); }else{ return value; } }},{key:'__getValue',value:function __getValue() { var value=this._strings[0]; for(var i=0;i<this._values.length;++i){ value+=this.__transformValue(this._values[i])+this._strings[1+i]; } return value; }},{key:'__attach',value:function __attach() { for(var i=0;i<this._values.length;++i){ if(this._values[i]instanceof Animated){ this._values[i].__addChild(this); } } }},{key:'__detach',value:function __detach() { for(var i=0;i<this._values.length;++i){ if(this._values[i]instanceof Animated){ this._values[i].__removeChild(this); } } }}]);return AnimatedTemplate;}(AnimatedWithChildren); module.exports=AnimatedTemplate;