Skip to content

Commit 0615f4b

Browse files
committed
🚀 RELEASE: v2.1.0
1 parent 560a52d commit 0615f4b

File tree

9 files changed

+38
-26
lines changed

9 files changed

+38
-26
lines changed

demo-app/package-lock.json

Lines changed: 6 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

demo-app/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
"react-dom": "^17.0.2",
1616
"react-router-dom": "^6.0.2",
1717
"react-scripts": "4.0.3",
18-
"react-ui-scrollspy": "file:react-ui-scrollspy-2.0.0.tgz",
18+
"react-ui-scrollspy": "file:react-ui-scrollspy-2.0.1.tgz",
1919
"typescript": "^4.4.4",
2020
"web-vitals": "^1.1.2"
2121
},

demo-app/src/pages/Demo1.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
import Center from "../components/Center/Center";
22
import Navigation from "../components/Demo1/Navigation";
3-
import ScrollSpy from "../components/src";
3+
// import ScrollSpy from "../components/src";
4+
import ScrollSpy from "react-ui-scrollspy";
45

56
interface Props {}
67

78
const Demo1 = (props: Props) => {
89
return (
910
<>
1011
<Navigation />
11-
<ScrollSpy scrollThrottle={100}>
12+
<ScrollSpy scrollThrottle={100} useBoxMethod={false}>
1213
<Center id="orange" backgroundColor={"orange"}>
1314
<h1>Orange</h1>
1415
</Center>

demo-app/src/pages/Demo2.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import React, { useRef } from "react";
22
import Center from "../components/Center/Center";
3-
import ScrollSpy from "../components/src";
3+
// import ScrollSpy from "../components/src";
4+
import ScrollSpy from "react-ui-scrollspy";
45

56
interface Props {}
67

@@ -77,10 +78,10 @@ const Demo2 = (props: Props) => {
7778
// }}
7879
>
7980
<ScrollSpy
80-
useBoxMethod
8181
// parentScrollContainerRef={parentScrollContainerRef}
8282
activeClass="ss-active-demo-2"
8383
scrollThrottle={100}
84+
useBoxMethod
8485
>
8586
<Center id="section-1" backgroundColor="orange" height="150vh">
8687
<p>Section 1</p>

dev.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,11 @@ creates a `.tgz`
1414
```bash
1515
npm run build
1616
npm pack
17-
mv react-ui-scrollspy-2.0.0.tgz ./demo-app
17+
mv react-ui-scrollspy-2.1.0.tgz ./demo-app
1818
cd demo-app
1919
npm uninstall react-ui-scrollspy
20-
npm install react-ui-scrollspy-2.0.0.tgz --production
20+
npm install react-ui-scrollspy-2.1.0.tgz --production
21+
cd ..
2122
```
2223

2324
## Commit Messages

dist/index.js

Lines changed: 11 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/index.js.map

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,6 +1,6 @@
11
{
22
"name": "react-ui-scrollspy",
3-
"version": "2.0.1",
3+
"version": "2.1.0",
44
"description": "Simple, Easy To Use and Customisable ScrollSpy component for react with callback, typescript and throttle support among others",
55
"main": "dist/index.js",
66
"scripts": {

src/ScrollSpy/ScrollSpy.tsx

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,11 +88,17 @@ const ScrollSpy = ({
8888
const rectInView = el.getBoundingClientRect();
8989

9090
if (useBoxMethod) {
91-
const hitbox_top = window.innerHeight;
91+
const useHeight = parentScrollContainerRef?.current
92+
? parentScrollContainerRef?.current.offsetHeight
93+
: window.innerHeight;
94+
const hitbox_top = useHeight;
9295
const element_top = rectInView.top;
93-
const element_bottom = rectInView.top + window.innerHeight;
96+
const element_bottom = rectInView.top + useHeight;
9497

95-
return hitbox_top < element_bottom && hitbox_top > element_top;
98+
return (
99+
hitbox_top < element_bottom + offsetBottom &&
100+
hitbox_top > element_top - offsetTop
101+
);
96102
} else {
97103
// this decides how much of the element should be visible
98104
const leniency = parentScrollContainerRef?.current

0 commit comments

Comments
 (0)