addimated
Version:
An always interruptable, declarative animation library for React
95 lines (78 loc) • 2.5 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 { AnimatedTransform } from "./AnimatedTransform";
import { AnimatedWithChildren } from "./AnimatedWithChildren";
import { FlattenStyle } from "./FlattenStyle";
var AnimatedStyle =
/*#__PURE__*/
function (_AnimatedWithChildren) {
_inherits(AnimatedStyle, _AnimatedWithChildren);
function AnimatedStyle(style) {
var _this;
_classCallCheck(this, AnimatedStyle);
_this = _possibleConstructorReturn(this, _getPrototypeOf(AnimatedStyle).call(this));
style = FlattenStyle(style) || {};
if (style.transform && !(style.transform instanceof Animated)) {
style = _objectSpread({}, style, {
transform: new AnimatedTransform(style.transform)
});
}
_this.style = style;
return _this;
}
_createClass(AnimatedStyle, [{
key: "__getValue",
value: function __getValue() {
var style = {};
for (var key in this.style) {
var value = this.style[key];
if (value instanceof Animated) {
style[key] = value.__getValue();
} else {
style[key] = value;
}
}
return style;
}
}, {
key: "__getAnimatedValue",
value: function __getAnimatedValue() {
var style = {};
for (var key in this.style) {
var value = this.style[key];
if (value instanceof Animated) {
style[key] = value.__getAnimatedValue();
}
}
return style;
}
}, {
key: "__attach",
value: function __attach() {
for (var key in this.style) {
var value = this.style[key];
if (value instanceof Animated) {
value.__addChild(this);
}
}
}
}, {
key: "__detach",
value: function __detach() {
for (var key in this.style) {
var value = this.style[key];
if (value instanceof Animated) {
value.__removeChild(this);
}
}
}
}]);
return AnimatedStyle;
}(AnimatedWithChildren);
export { AnimatedStyle };
//# sourceMappingURL=AnimatedStyle.js.map