hongluan-ui
Version:
Hongluan Component Library for Vue 3
36 lines (33 loc) • 730 B
JavaScript
import BTween from 'b-tween';
import { isString, isFunction } from '@vue/shared';
function findNode(dom, selector) {
const s = isString(selector) && selector[0] === "#" ? `[id='${selector.replace("#", "")}']` : selector;
try {
return dom.querySelector(s);
} catch (e) {
return null;
}
}
function slide(el, top, cb) {
const tween = new BTween({
from: {
scrollTop: el.scrollTop
},
to: {
scrollTop: top
},
easing: "quartOut",
duration: 300,
onUpdate: (keys) => {
el.scrollTop = keys.scrollTop;
},
onFinish: () => {
if (isFunction(cb)) {
cb();
}
}
});
tween.start();
}
export { findNode, slide };
//# sourceMappingURL=utils.mjs.map