Skip to content

Commit 300bb29

Browse files
committed
bugfix
1 parent 8caf1cc commit 300bb29

File tree

5 files changed

+19
-16
lines changed

5 files changed

+19
-16
lines changed

README.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# react-scrollsy v1.1.2 ![](https://img.badgesize.io/olarsson/react-scrollsy/master/dist/react-scrollsy.es.js)
1+
# react-scrollsy v1.1.3 ![](https://img.badgesize.io/olarsson/react-scrollsy/master/dist/react-scrollsy.es.js)
22

33
An ambitious light-weight react module written in TypeScript for tracking scroll progress in a performant way. Developed for use with spring based animation libraries such as react-spring, but can be used with or without any library.
44

@@ -180,6 +180,9 @@ Creates a function which returns a `scrollObject` object as such:
180180

181181
### Whats new
182182

183+
##### Version 1.1.3
184+
- [x] Bugfix, incorrect height calculation after adding triggers
185+
183186
##### Version 1.1.2
184187
- [x] Triggers added, onEnter/onLeave
185188
- [x] Examples update with the use of triggers

dist/react-scrollsy.es.js

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { memo as L, useState as p, useEffect as g } from "react";
1+
import { memo as R, useState as p, useEffect as g } from "react";
22
import { jsx as k } from "react/jsx-runtime";
33
var y = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {};
44
function z(e) {
@@ -126,7 +126,7 @@ const x = (e, n) => {
126126
s = n.containerHeight, u = x(e, n.element), i === "onEnter" && (u -= n.containerHeight);
127127
break;
128128
case "elem":
129-
u = x(e, n.element), i === "onEnter" ? (s = e.getBoundingClientRect().bottom, u -= n.containerHeight) : i === "onLeave" && (s = e.scrollHeight);
129+
u = x(e, n.element), i === "onEnter" ? (s = e.scrollHeight, u -= n.containerHeight) : i === "onLeave" && (s = e.scrollHeight);
130130
break;
131131
}
132132
if (r) {
@@ -180,10 +180,10 @@ const x = (e, n) => {
180180
start: f,
181181
end: d
182182
};
183-
}, R = {
183+
}, q = {
184184
resizeThrottle: 150
185185
// scrollThrottle: 200
186-
}, q = {
186+
}, L = {
187187
progress: 0,
188188
scrollData: {
189189
containerHeight: 0,
@@ -194,7 +194,7 @@ const x = (e, n) => {
194194
},
195195
start: 0,
196196
end: 0
197-
}, _ = (e, n = q) => typeof e == "function" ? e({ scrollObject: n, children: e }) : e, J = L(({ scrollData: e, children: n, elem: i, settings: r, onStart: t, onEnd: o }) => {
197+
}, _ = (e, n = L) => typeof e == "function" ? e({ scrollObject: n, children: e }) : e, K = R(({ scrollData: e, children: n, elem: i, settings: r, onStart: t, onEnd: o }) => {
198198
const { trigger: s = "onEnter", offsetTop: u, offsetBottom: c, duration: l } = r, [a, f] = p(!1), [d, m] = p(!1), [h, w] = p(!1);
199199
if (g(() => {
200200
a && typeof t == "function" && t();
@@ -203,7 +203,7 @@ const x = (e, n) => {
203203
}, [d]), g(() => {
204204
i != null && i.current && w(!0);
205205
}, [i]), !h)
206-
return _(n, q);
206+
return _(n, L);
207207
const S = W(i.current, e, s, u, c, l), { progress: v } = S;
208208
return v > 0 && v < 1 && a === !1 && typeof t == "function" && f(!0), v <= 0 && a === !0 && typeof t == "function" && f(!1), v >= 1 && d === !1 && typeof o == "function" && m(!0), v < 1 && d === !0 && typeof o == "function" && m(!1), _(n, S);
209209
}), P = ({ scrollData: e, children: n }) => typeof n == "function" ? n({
@@ -215,7 +215,7 @@ const x = (e, n) => {
215215
element: e.element
216216
},
217217
children: n
218-
}) : n, K = ({ children: e, scrollThrottle: n, resizeThrottle: i = R.resizeThrottle }) => {
218+
}) : n, Q = ({ children: e, scrollThrottle: n, resizeThrottle: i = q.resizeThrottle }) => {
219219
const r = document == null ? void 0 : document.documentElement;
220220
if (!r)
221221
throw new Error("No document.documentElement found.");
@@ -250,7 +250,7 @@ const x = (e, n) => {
250250
},
251251
children: e
252252
});
253-
}, Q = ({ children: e, scrollThrottle: n, scrollingElement: i, resizeThrottle: r }) => {
253+
}, X = ({ children: e, scrollThrottle: n, scrollingElement: i, resizeThrottle: r }) => {
254254
const [t, o] = p(!1), [s, u] = p(null), c = P({
255255
scrollData: {
256256
scrollTop: 0,
@@ -268,7 +268,7 @@ const x = (e, n) => {
268268
children: e,
269269
customScrollingElement: n,
270270
scrollThrottle: i,
271-
resizeThrottle: r = R.resizeThrottle
271+
resizeThrottle: r = q.resizeThrottle
272272
}) => {
273273
const t = n;
274274
if (!t)
@@ -308,7 +308,7 @@ const x = (e, n) => {
308308
});
309309
};
310310
export {
311-
J as ScrollTracker,
312-
Q as ScrollTrackerCustom,
313-
K as ScrollTrackerDocument
311+
K as ScrollTracker,
312+
X as ScrollTrackerCustom,
313+
Q as ScrollTrackerDocument
314314
};

dist/react-scrollsy.umd.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.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "react-scrollsy",
33
"private": false,
4-
"version": "1.1.2",
4+
"version": "1.1.3",
55
"description": "",
66
"license": "MIT",
77
"type": "module",

src/functions/elementVisibility.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ const elementVisibility = function (el: HTMLElement, scrollData: IScrollDataBase
2626
elOffset = elOffsetTopRelativeToContainer(el, scrollData.element)
2727

2828
if (trigger === 'onEnter') {
29-
heightDuration = el.getBoundingClientRect().bottom;
29+
heightDuration = el.scrollHeight;
3030
elOffset -= scrollData.containerHeight;
3131
} else if (trigger === 'onLeave') {
3232
heightDuration = el.scrollHeight;

0 commit comments

Comments
 (0)