[improvement] Tab: support string type of line-width & line-height (#3514)

This commit is contained in:
neverland
2019-06-14 17:29:30 +08:00
committed by GitHub
parent c05124b3ec
commit 7fbf943a2d
11 changed files with 52 additions and 58 deletions
+17
View File
@@ -0,0 +1,17 @@
import { raf } from '../utils/dom/raf';
export function scrollLeftTo(el: HTMLElement, to: number, duration: number) {
let count = 0;
const from = el.scrollLeft;
const frames = duration === 0 ? 1 : Math.round((duration * 1000) / 16);
function animate() {
el.scrollLeft += (to - from) / frames;
if (++count < frames) {
raf(animate);
}
}
animate();
}