You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
45 lines
1.1 KiB
45 lines
1.1 KiB
// =============================== Motion ===============================
|
|
export function getMotionName(prefixCls, transitionName, animationName) {
|
|
var motionName = transitionName;
|
|
|
|
if (!motionName && animationName) {
|
|
motionName = "".concat(prefixCls, "-").concat(animationName);
|
|
}
|
|
|
|
return motionName;
|
|
} // ================================ UUID ================================
|
|
|
|
var uuid = -1;
|
|
export function getUUID() {
|
|
uuid += 1;
|
|
return uuid;
|
|
} // =============================== Offset ===============================
|
|
|
|
function getScroll(w, top) {
|
|
var ret = w["page".concat(top ? 'Y' : 'X', "Offset")];
|
|
var method = "scroll".concat(top ? 'Top' : 'Left');
|
|
|
|
if (typeof ret !== 'number') {
|
|
var d = w.document;
|
|
ret = d.documentElement[method];
|
|
|
|
if (typeof ret !== 'number') {
|
|
ret = d.body[method];
|
|
}
|
|
}
|
|
|
|
return ret;
|
|
}
|
|
|
|
export function offset(el) {
|
|
var rect = el.getBoundingClientRect();
|
|
var pos = {
|
|
left: rect.left,
|
|
top: rect.top
|
|
};
|
|
var doc = el.ownerDocument;
|
|
var w = doc.defaultView || doc.parentWindow;
|
|
pos.left += getScroll(w);
|
|
pos.top += getScroll(w, true);
|
|
return pos;
|
|
} |