Skip to content
Snippets Groups Projects
Commit d63b0401 authored by Daniel Kurowski's avatar Daniel Kurowski
Browse files

Renamed scrollTo() to scrollToTarget()

parent 35195ccd
No related branches found
No related tags found
1 merge request!7Improve structure
import {scrollTo} from './scrollTo';
import {scrollToTarget} from './scrollToTarget';
import {assert} from './assert';
import {HashTarget} from './HashTarget';
......@@ -11,6 +11,6 @@ export function initializeOnLinkClickScroll(): void
assert(element !== null);
event.preventDefault();
scrollTo(HashTarget.fromString(element.hash, document));
scrollToTarget(HashTarget.fromString(element.hash, document));
})));
}
import {scrollTo} from './scrollTo';
import {scrollToTarget} from './scrollToTarget';
import {HashTarget} from './HashTarget';
import {assert} from './assert';
......@@ -36,6 +36,6 @@ export function initializeOnLoadScroll(): void
// Then, scroll down to it smoothly.
assert(hashTarget !== null, 'Hash target should be set on DOM loaded.');
scrollTo(hashTarget);
scrollToTarget(hashTarget);
});
}
import * as Velocity from 'velocity-animate';
import {HashTarget} from './HashTarget';
export function scrollTo(hash: HashTarget): void
export function scrollToTarget(hashTarget: HashTarget): void
{
Velocity.animate(hash.getElement(), 'scroll', {
Velocity.animate(hashTarget.getElement(), 'scroll', {
duration: 1200, // todo: different depending on offset from page top?
easing: 'ease-in-skip-out',
complete: () => window.location.hash = hash.getHash(),
complete: () => window.location.hash = hashTarget.getHash(),
});
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment