add autoMin

This commit is contained in:
Harvey committed 2020-05-19 11:47:45 +08:00
1 parent 33a7e1193d
commit b202c21a7f
11 files changed
+150 -18

No files matched your search

+9
View File
@@ -64,3 +64,12 @@ export function tooltip(target, msg, pos = 'up') {
target.setAttribute('aria-label', msg);
target.setAttribute('data-balloon-pos', pos);
}
export function isInViewport(el) {
const rect = el.getBoundingClientRect();
const windowHeight = window.innerHeight || document.documentElement.clientHeight;
const windowWidth = window.innerWidth || document.documentElement.clientWidth;
const vertInView = rect.top <= windowHeight && rect.top + rect.height >= 0;
const horInView = rect.left <= windowWidth && rect.left + rect.width >= 0;
return vertInView && horInView;
}