Skip to content

Commit

Permalink
feat: Setup a first panelSnap without jQuery
Browse files Browse the repository at this point in the history
  • Loading branch information
guidobouman committed Apr 12, 2018
1 parent 7168435 commit 7808c2b
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions src/panelSnap.js
@@ -0,0 +1,33 @@
import { getScrollingElement } from './utilities';

const defaultOptions = {
container: document.body,
panelSelector: '> section',
offset: 0,
directionThreshold: 50,
delay: 0,
slideSpeed: 200,
easing: t => t,
onSnapStart: e => e,
onSnapFinish: e => e,
onActivate: e => e,
};

export default class PanelSnap {
constructor(options) {
this.options = {
...defaultOptions,
...options,
};

this.container = this.options.container;
this.scrollingContainer = getScrollingElement(this.container);
this.panelList = this.container.querySelectorAll(this.options.panelSelector);

this.isEnabled = true;
this.isMouseDown = false;
this.animation = null;
this.currentScrollOffset = this.scrollingContainer.scrollTop;
this.targetScrollOffset = this.currentScrollOffset;
}
}

0 comments on commit 7808c2b

Please sign in to comment.