add anchor component

This commit is contained in:
zhigang.li 2018-04-12 17:49:55 +08:00
parent eeeceb5446
commit 43513f702c
13 changed files with 434 additions and 4 deletions

View file

@ -138,7 +138,7 @@ function deepCopy(data) {
export {deepCopy};
// scrollTop animation
export function scrollTop(el, from = 0, to, duration = 500) {
export function scrollTop(el, from = 0, to, duration = 500, endCallback) {
if (!window.requestAnimationFrame) {
window.requestAnimationFrame = (
window.webkitRequestAnimationFrame ||
@ -153,7 +153,10 @@ export function scrollTop(el, from = 0, to, duration = 500) {
const step = Math.ceil(difference / duration * 50);
function scroll(start, end, step) {
if (start === end) return;
if (start === end) {
endCallback && endCallback();
return;
}
let d = (start + step > end) ? end : start + step;
if (start > end) {
@ -322,3 +325,5 @@ export function setMatchMedia () {
window.matchMedia = window.matchMedia || matchMediaPolyfill;
}
}
export const sharpMatcherRegx = /#([^#]+)$/;

View file

@ -33,4 +33,4 @@ export const off = (function() {
}
};
}
})();
})();