Skip to content

Commit e3bbc8d

Browse files
authored
Fix scrollspy reset when scrolling above the countUp (#295)
* 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
1 parent 9680601 commit e3bbc8d

File tree

6 files changed

+11959
-254
lines changed

6 files changed

+11959
-254
lines changed

dist/countUp.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,7 @@ var CountUp = /** @class */ (function () {
158158
return;
159159
var bottomOfScroll = window.innerHeight + window.scrollY;
160160
var rect = self.el.getBoundingClientRect();
161+
var topOfEl = rect.top + window.pageYOffset;
161162
var bottomOfEl = rect.top + rect.height + window.pageYOffset;
162163
if (bottomOfEl < bottomOfScroll && bottomOfEl > window.scrollY && self.paused) {
163164
// in view
@@ -166,8 +167,9 @@ var CountUp = /** @class */ (function () {
166167
if (self.options.scrollSpyOnce)
167168
self.once = true;
168169
}
169-
else if (window.scrollY > bottomOfEl && !self.paused) {
170-
// scrolled past
170+
else if ((window.scrollY > bottomOfEl || topOfEl > bottomOfScroll) &&
171+
!self.paused) {
172+
// out of view
171173
self.reset();
172174
}
173175
};

dist/countUp.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/countUp.umd.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,7 @@
164164
return;
165165
var bottomOfScroll = window.innerHeight + window.scrollY;
166166
var rect = self.el.getBoundingClientRect();
167+
var topOfEl = rect.top + window.pageYOffset;
167168
var bottomOfEl = rect.top + rect.height + window.pageYOffset;
168169
if (bottomOfEl < bottomOfScroll && bottomOfEl > window.scrollY && self.paused) {
169170
// in view
@@ -172,8 +173,9 @@
172173
if (self.options.scrollSpyOnce)
173174
self.once = true;
174175
}
175-
else if (window.scrollY > bottomOfEl && !self.paused) {
176-
// scrolled past
176+
else if ((window.scrollY > bottomOfEl || topOfEl > bottomOfScroll) &&
177+
!self.paused) {
178+
// out of view
177179
self.reset();
178180
}
179181
};

0 commit comments

Comments
 (0)