add anchor component
This commit is contained in:
parent
eeeceb5446
commit
43513f702c
13 changed files with 434 additions and 4 deletions
|
@ -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 = /#([^#]+)$/;
|
||||
|
|
|
@ -33,4 +33,4 @@ export const off = (function() {
|
|||
}
|
||||
};
|
||||
}
|
||||
})();
|
||||
})();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue