Skip to content

Commit

Permalink
Fix acceleration in ScrollerPlugin
Browse files Browse the repository at this point in the history
  • Loading branch information
Drafteed committed Aug 22, 2022
1 parent da14151 commit 4d73fb0
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 8 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "reeller",
"version": "0.0.3",
"version": "0.0.4",
"description": "A powerful, flexible and modern library for creating the running text effect, also known as marquee or ticker.",
"keywords": [
"marquee",
Expand Down
2 changes: 1 addition & 1 deletion src/module/Reeller.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* https://github.com/Cuberto/reeller
* https://cuberto.com/
*
* @version 0.0.3
* @version 0.0.4
* @license The MIT License (MIT)
* @author Cuberto, Artem Dordzhiev (Draft)
*/
Expand Down
17 changes: 11 additions & 6 deletions src/plugin/ScrollerPlugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,12 +71,6 @@ export default class ScrollerPlugin {
let reachedEnd = true;

this.tickerFn = () => {
if (this.reeller.paused) {
this.gsap.killTweensOf(this.tl);
this.tl.timeScale(lastDirection * this.options.threshold);
return;
}

const scrollPos = this.getScrollPos();
let velocity = scrollPos - lastScrollPos;

Expand All @@ -88,6 +82,17 @@ export default class ScrollerPlugin {
velocity *= -1;
}

if (this.reeller.paused) {
lastDirection = Math.sign(velocity);
lastScrollPos = scrollPos;
if (!reachedEnd) {
this.gsap.killTweensOf(this.tl);
reachedEnd = true;
}
this.tl.timeScale(lastDirection * this.options.threshold);
return;
}

if (velocity) {
const delta = velocity * this.options.multiplier;
const timeScale =
Expand Down

0 comments on commit 4d73fb0

Please sign in to comment.