1
0
mirror of https://github.com/webslides/WebSlides.git synced 2025-09-09 20:50:39 +02:00
This commit is contained in:
Antonio Laguna
2017-05-29 10:16:40 +02:00
parent 8a9ea037c0
commit c5ee83c940
17 changed files with 147 additions and 255 deletions

View File

@@ -1,6 +1,6 @@
import Easings from './easing';
const SCROLLABLE_CONTAINER = document.getElementById('webslides');
let SCROLLABLE_CONTAINER = null;
/**
* Smoothly scrolls to a given Y position using Easing.Swing. It'll run a
@@ -10,6 +10,10 @@ const SCROLLABLE_CONTAINER = document.getElementById('webslides');
* @param {function} cb Callback function to call upon completion.
*/
export default function scrollTo(y, duration = 500, cb = () => {}) {
if (!SCROLLABLE_CONTAINER) {
SCROLLABLE_CONTAINER = document.getElementById('webslides');
}
const delta = y - SCROLLABLE_CONTAINER.scrollTop;
const startLocation = SCROLLABLE_CONTAINER.scrollTop;
const increment = 16;