addimated
Version:
An always interruptable, declarative animation library for React
56 lines (48 loc) • 1.9 kB
JavaScript
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 invariant from "invariant";
import { Animated } from "./Animated";
import { AnimatedWithChildren } from "./AnimatedWithChildren";
import { Interpolation } from "./Interpolation";
var AnimatedInterpolation =
/*#__PURE__*/
function (_AnimatedWithChildren) {
_inherits(AnimatedInterpolation, _AnimatedWithChildren);
function AnimatedInterpolation(parent, interpolation) {
var _this;
_classCallCheck(this, AnimatedInterpolation);
_this = _possibleConstructorReturn(this, _getPrototypeOf(AnimatedInterpolation).call(this));
_this.parent = parent;
_this.interpolation = interpolation;
return _this;
}
_createClass(AnimatedInterpolation, [{
key: "__getValue",
value: function __getValue() {
var parentValue = this.parent.__getValue();
!(typeof parentValue === "number") ? process.env.NODE_ENV !== "production" ? invariant(false, "Cannot interpolate an input which is not a number.") : invariant(false) : void 0;
return this.interpolation(parentValue);
}
}, {
key: "interpolate",
value: function interpolate(config) {
return new AnimatedInterpolation(this, Interpolation.create(config));
}
}, {
key: "__attach",
value: function __attach() {
this.parent.__addChild(this);
}
}, {
key: "__detach",
value: function __detach() {
this.parent.__removeChild(this);
}
}]);
return AnimatedInterpolation;
}(AnimatedWithChildren);
export { AnimatedInterpolation };
//# sourceMappingURL=AnimatedInterpolation.js.map