Skip to content

Commit

Permalink
Fix scrollspy reset when scrolling above the countUp (#295)
Browse files Browse the repository at this point in the history
* Fix scrollspy reset when scrolling above the countUp

* Fix scrollspy reset when scrolling above the countUp

* Fix scrollspy reset when scrolling above the countUp

* correct spaces

* replace tabs with spaces

* add spaces for indent and remove empty lines

* indent function

* indent line 119
  • Loading branch information
paidge authored Jan 28, 2023
1 parent 9680601 commit e3bbc8d
Show file tree
Hide file tree
Showing 6 changed files with 11,959 additions and 254 deletions.
6 changes: 4 additions & 2 deletions dist/countUp.js
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@ var CountUp = /** @class */ (function () {
return;
var bottomOfScroll = window.innerHeight + window.scrollY;
var rect = self.el.getBoundingClientRect();
var topOfEl = rect.top + window.pageYOffset;
var bottomOfEl = rect.top + rect.height + window.pageYOffset;
if (bottomOfEl < bottomOfScroll && bottomOfEl > window.scrollY && self.paused) {
// in view
Expand All @@ -166,8 +167,9 @@ var CountUp = /** @class */ (function () {
if (self.options.scrollSpyOnce)
self.once = true;
}
else if (window.scrollY > bottomOfEl && !self.paused) {
// scrolled past
else if ((window.scrollY > bottomOfEl || topOfEl > bottomOfScroll) &&
!self.paused) {
// out of view
self.reset();
}
};
Expand Down
2 changes: 1 addition & 1 deletion dist/countUp.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 4 additions & 2 deletions dist/countUp.umd.js
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@
return;
var bottomOfScroll = window.innerHeight + window.scrollY;
var rect = self.el.getBoundingClientRect();
var topOfEl = rect.top + window.pageYOffset;
var bottomOfEl = rect.top + rect.height + window.pageYOffset;
if (bottomOfEl < bottomOfScroll && bottomOfEl > window.scrollY && self.paused) {
// in view
Expand All @@ -172,8 +173,9 @@
if (self.options.scrollSpyOnce)
self.once = true;
}
else if (window.scrollY > bottomOfEl && !self.paused) {
// scrolled past
else if ((window.scrollY > bottomOfEl || topOfEl > bottomOfScroll) &&
!self.paused) {
// out of view
self.reset();
}
};
Expand Down
Loading

0 comments on commit e3bbc8d

Please sign in to comment.