amis-rpc-design/node_modules/antd/lib/affix/utils.js

27 lines
863 B
JavaScript
Raw Normal View History

2023-10-07 19:42:30 +08:00
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.getFixedBottom = getFixedBottom;
exports.getFixedTop = getFixedTop;
exports.getTargetRect = getTargetRect;
function getTargetRect(target) {
return target !== window ? target.getBoundingClientRect() : {
top: 0,
bottom: window.innerHeight
};
}
function getFixedTop(placeholderRect, targetRect, offsetTop) {
if (offsetTop !== undefined && targetRect.top > placeholderRect.top - offsetTop) {
return offsetTop + targetRect.top;
}
return undefined;
}
function getFixedBottom(placeholderRect, targetRect, offsetBottom) {
if (offsetBottom !== undefined && targetRect.bottom < placeholderRect.bottom + offsetBottom) {
const targetBottomOffset = window.innerHeight - targetRect.bottom;
return offsetBottom + targetBottomOffset;
}
return undefined;
}