Files
video-gen/video-gen-admin/node_modules/@rc-component/trigger/lib/hooks/useOffsetStyle.js
T
2026-05-25 17:08:18 +08:00

41 lines
1.0 KiB
JavaScript

"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = useOffsetStyle;
function useOffsetStyle(isMobile, ready, open, align, offsetR, offsetB, offsetX, offsetY) {
// >>>>> Offset
const AUTO = 'auto';
const offsetStyle = isMobile ? {} : {
left: '-1000vw',
top: '-1000vh',
right: AUTO,
bottom: AUTO
};
// Set align style
if (!isMobile && (ready || !open)) {
const {
points
} = align;
const dynamicInset = align.dynamicInset || align._experimental?.dynamicInset;
const alignRight = dynamicInset && points[0][1] === 'r';
const alignBottom = dynamicInset && points[0][0] === 'b';
if (alignRight) {
offsetStyle.right = offsetR;
offsetStyle.left = AUTO;
} else {
offsetStyle.left = offsetX;
offsetStyle.right = AUTO;
}
if (alignBottom) {
offsetStyle.bottom = offsetB;
offsetStyle.top = AUTO;
} else {
offsetStyle.top = offsetY;
offsetStyle.bottom = AUTO;
}
}
return offsetStyle;
}