PromoCursed/node_modules/antd/lib/drawer/style/motion.js

59 lines
1.6 KiB
JavaScript
Raw Normal View History

2024-08-20 23:25:37 +04:00
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
const getMoveTranslate = direction => {
const value = '100%';
return {
left: `translateX(-${value})`,
right: `translateX(${value})`,
top: `translateY(-${value})`,
bottom: `translateY(${value})`
}[direction];
};
const getEnterLeaveStyle = (startStyle, endStyle) => ({
'&-enter, &-appear': Object.assign(Object.assign({}, startStyle), {
'&-active': endStyle
}),
'&-leave': Object.assign(Object.assign({}, endStyle), {
'&-active': startStyle
})
});
const getFadeStyle = (from, duration) => Object.assign({
'&-enter, &-appear, &-leave': {
'&-start': {
transition: 'none'
},
'&-active': {
transition: `all ${duration}`
}
}
}, getEnterLeaveStyle({
opacity: from
}, {
opacity: 1
}));
const getPanelMotionStyles = (direction, duration) => [getFadeStyle(0.7, duration), getEnterLeaveStyle({
transform: getMoveTranslate(direction)
}, {
transform: 'none'
})];
const genMotionStyle = token => {
const {
componentCls,
motionDurationSlow
} = token;
return {
[componentCls]: {
// ======================== Mask ========================
[`${componentCls}-mask-motion`]: getFadeStyle(0, motionDurationSlow),
// ======================= Panel ========================
[`${componentCls}-panel-motion`]: ['left', 'right', 'top', 'bottom'].reduce((obj, direction) => Object.assign(Object.assign({}, obj), {
[`&-${direction}`]: getPanelMotionStyles(direction, motionDurationSlow)
}), {})
}
};
};
var _default = exports.default = genMotionStyle;