@wix/design-system
Version:
@wix/design-system
70 lines (69 loc) • 2.58 kB
JavaScript
"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
exports.__esModule = true;
exports.default = void 0;
var _react = _interopRequireDefault(require("react"));
var _BounceAnimationSt = require("./BounceAnimation.st.css.js");
var _Animate = _interopRequireDefault(require("../Animate"));
var _BounceAnimation2 = require("./BounceAnimation.constants");
var _utils = require("../Animate/utils");
var _jsxFileName = "/home/builduser/work/57e038ea7326c1ec/packages/wix-design-system/dist/cjs/BounceAnimation/BounceAnimation.tsx";
/** Bounce Animation*/
class BounceAnimation extends _react.default.PureComponent {
constructor(props) {
super(props);
this.rootRef = /*#__PURE__*/_react.default.createRef();
this.getAnimationSize = () => {
var _this$rootRef$current, _this$rootRef$current2;
var childWidth = (_this$rootRef$current = (_this$rootRef$current2 = this.rootRef.current) == null ? void 0 : _this$rootRef$current2.offsetWidth) !== null && _this$rootRef$current !== void 0 ? _this$rootRef$current : 0;
var _CHILD_WIDTH_RANGE$me = _BounceAnimation2.CHILD_WIDTH_RANGE.medium,
from = _CHILD_WIDTH_RANGE$me.from,
to = _CHILD_WIDTH_RANGE$me.to;
return (0, _utils.isValueInRange)(childWidth, from, to) ? _BounceAnimation2.CHILD_SIZE.medium : _BounceAnimation2.CHILD_SIZE.small;
};
this.state = {
animationSize: undefined
};
}
componentDidMount() {
var animationSize = this.getAnimationSize();
this.setState({
animationSize
});
}
render() {
var _this$props = this.props,
dataHook = _this$props.dataHook,
active = _this$props.active,
onEnd = _this$props.onEnd,
onStart = _this$props.onStart,
loop = _this$props.loop,
children = _this$props.children,
delay = _this$props.delay;
var animationSize = this.state.animationSize;
return /*#__PURE__*/_react.default.createElement(_Animate.default, {
dataHook: dataHook,
delay: delay,
animateClasses: (0, _BounceAnimationSt.st)(_BounceAnimationSt.classes.root, {
active,
loop,
size: animationSize
}),
onEnd: onEnd,
onStart: onStart,
ref: this.rootRef,
__self: this,
__source: {
fileName: _jsxFileName,
lineNumber: 47,
columnNumber: 7
}
}, children);
}
}
Object.assign(BounceAnimation, {
displayName: 'Bounce',
defaultProps: {}
});
var _default = exports.default = BounceAnimation;
//# sourceMappingURL=BounceAnimation.js.map