Skip to content

Commit

Permalink
feat: add missing duration setting
Browse files Browse the repository at this point in the history
BREAKING CHANGE: The option slideSpeed has been renamed to duration. Also, the default value for duration is
now 300ms, instead of 200ms.
  • Loading branch information
guidobouman committed May 12, 2018
1 parent 913cde7 commit 6c6d83d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
4 changes: 2 additions & 2 deletions docs/new.html
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ <h1>
panelSelector: '> section',
directionThreshold: 50,
delay: 0,
slideSpeed: 200,
duration: 300,
easing: function(t) { return t },
};

Expand All @@ -90,7 +90,7 @@ <h1>Options explained</h1>
<dd>(interger) The amount of pixels required to scroll before the plugin detects a direction and snaps to the next panel.</dd>
<dt>delay</dt>
<dd>(integer) The amount of miliseconds the plugin pauzes before snapping to a panel.</dd>
<dt>slideSpeed</dt>
<dt>duration</dt>
<dd>(integer) The amount of miliseconds in which the plugin snaps to the desired panel.</dd>
<dt>easing</dt>
<dd>(function) An easing function specificing the snapping motion.</dd>
Expand Down
12 changes: 7 additions & 5 deletions src/panelSnap.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const defaultOptions = {
panelSelector: '> section',
directionThreshold: 50,
delay: 0,
slideSpeed: 200,
duration: 300,
easing: t => t,
};

Expand Down Expand Up @@ -176,12 +176,14 @@ export default class PanelSnap {

this.targetScrollOffset = getTargetScrollOffset(this.container, panel, toBottom, toRight);

const start = 0;
const end = TWEEN_MAX_VALUE;
const duration = 300;
this.animation = new Tweezer({
start: 0,
end: TWEEN_MAX_VALUE,
duration: this.options.duration,
});

this.animation = new Tweezer({ start, end, duration });
this.animation.on('tick', this.animationTick.bind(this));

this.animation.on('done', () => {
this.emit('snapStop', panel);
this.clearAnimation();
Expand Down

0 comments on commit 6c6d83d

Please sign in to comment.