Skip to content

Commit

Permalink
improve(slide): do not use translation easing while dragging
Browse files Browse the repository at this point in the history
  • Loading branch information
berndartmueller committed Aug 28, 2020
1 parent dbeb942 commit 3470358
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
11 changes: 6 additions & 5 deletions src/slide.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,13 +76,14 @@ export class Slide {
/**
* Start transition.
*
* @param value
* @param done
* @param value Position to translate to.
* @param easing Enable or disable transition easing.
* @param done Callback function after transition has ended.
*/
translate(value: number, done = noop) {
this.transitionEndCallback = done;
translate(value: number, { easing, done }: { easing?: boolean; done?: identity } = {}) {
this.transitionEndCallback = done || noop;

this.ref.style.transition = `transform ${this.settings.speed}ms ${this.settings.easing}`;
this.ref.style.transition = `transform ${this.settings.speed}ms ${easing ? this.settings.easing : 'ease'}`;
this.ref.style.transform = `translate3d(calc(${this.position}% + ${Math.round(value)}px), 0, 0)`;
}

Expand Down
7 changes: 5 additions & 2 deletions src/virchual.ts
Original file line number Diff line number Diff line change
Expand Up @@ -164,8 +164,11 @@ export class Virchual {
private goTo(control: 'prev' | 'next') {
const slide = this.slides[this.currentIndex];

slide.translate(-100, () => {
this.isBusy = false;
slide.translate(-100, {
easing: true,
done: () => {
this.isBusy = false;
},
});

const sign: Sign = control === 'prev' ? -1 : +1;
Expand Down

0 comments on commit 3470358

Please sign in to comment.