addimated
Version:
An always interruptable, declarative animation library for React
101 lines (82 loc) • 2.4 kB
JavaScript
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread";
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
import _createClass from "@babel/runtime/helpers/esm/createClass";
import _possibleConstructorReturn from "@babel/runtime/helpers/esm/possibleConstructorReturn";
import _getPrototypeOf from "@babel/runtime/helpers/esm/getPrototypeOf";
import _inherits from "@babel/runtime/helpers/esm/inherits";
import { Animated } from "./Animated";
import { AnimatedStyle } from "./AnimatedStyle";
var AnimatedProps =
/*#__PURE__*/
function (_Animated) {
_inherits(AnimatedProps, _Animated);
function AnimatedProps(props, callback) {
var _this;
_classCallCheck(this, AnimatedProps);
_this = _possibleConstructorReturn(this, _getPrototypeOf(AnimatedProps).call(this));
if (props.style) {
props = _objectSpread({}, props, {
style: new AnimatedStyle(props.style)
});
}
_this.props = props;
_this.callback = callback;
_this.__attach();
return _this;
}
_createClass(AnimatedProps, [{
key: "__getValue",
value: function __getValue() {
var props = {};
for (var key in this.props) {
var value = this.props[key];
if (value instanceof Animated) {
props[key] = value.__getValue();
} else {
props[key] = value;
}
}
return props;
}
}, {
key: "__getAnimatedValue",
value: function __getAnimatedValue() {
var props = {};
for (var key in this.props) {
var value = this.props[key];
if (value instanceof Animated) {
props[key] = value.__getAnimatedValue();
}
}
return props;
}
}, {
key: "__attach",
value: function __attach() {
for (var key in this.props) {
var value = this.props[key];
if (value instanceof Animated) {
value.__addChild(this);
}
}
}
}, {
key: "__detach",
value: function __detach() {
for (var key in this.props) {
var value = this.props[key];
if (value instanceof Animated) {
value.__removeChild(this);
}
}
}
}, {
key: "update",
value: function update() {
this.callback();
}
}]);
return AnimatedProps;
}(Animated);
export { AnimatedProps };
//# sourceMappingURL=AnimatedProps.js.map