41 lines
1.1 KiB
JavaScript
41 lines
1.1 KiB
JavaScript
|
"use strict";
|
||
|
|
||
|
Object.defineProperty(exports, "__esModule", {
|
||
|
value: true
|
||
|
});
|
||
|
exports.getMotionName = getMotionName;
|
||
|
exports.offset = offset;
|
||
|
// =============================== Motion ===============================
|
||
|
function getMotionName(prefixCls, transitionName, animationName) {
|
||
|
var motionName = transitionName;
|
||
|
if (!motionName && animationName) {
|
||
|
motionName = "".concat(prefixCls, "-").concat(animationName);
|
||
|
}
|
||
|
return motionName;
|
||
|
}
|
||
|
|
||
|
// =============================== 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;
|
||
|
}
|
||
|
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;
|
||
|
}
|