Skip to content
This repository was archived by the owner on May 1, 2025. It is now read-only.

Commit a6bfaf7

Browse files
committed
useHashScroll docs finished
1 parent b9d5498 commit a6bfaf7

File tree

5 files changed

+89
-12
lines changed

5 files changed

+89
-12
lines changed

.github/workflows/firebase-hosting-merge.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ on:
77
push:
88
paths:
99
- "website/**"
10-
- "website/**"
10+
- "docs/**"
1111
branches:
1212
- "main"
1313

.github/workflows/firebase-hosting-pull-request.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ on:
77
pull_request:
88
paths:
99
- "website/**"
10-
- "docs/**"
1110
branch:
1211
- main
1312

CHANGELOG.md

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,13 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/), and this
88

99
- [[Unreleased]](#unreleased)
1010
- [[v1.4.0] - (2020-12-03)](#v140---2020-12-03)
11-
- [[v1.3.2] - (2020-12-02)](#v132---2020-12-02)
1211
- [Added](#added)
13-
- [[v1.3.1] - (2020-11-30)](#v131---2020-11-30)
12+
- [[v1.3.2] - (2020-12-02)](#v132---2020-12-02)
1413
- [Added](#added-1)
15-
- [[v1.3.0] - (2020-11-27)](#v130---2020-11-27)
14+
- [[v1.3.1] - (2020-11-30)](#v131---2020-11-30)
1615
- [Added](#added-2)
16+
- [[v1.3.0] - (2020-11-27)](#v130---2020-11-27)
17+
- [Added](#added-3)
1718
- [Dependencies](#dependencies)
1819
- [[v1.2.3] - (2020-11-26)](#v123---2020-11-26)
1920
- [Removed](#removed)
@@ -22,15 +23,15 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/), and this
2223
- [[v1.2.1] - (2020-11-26)](#v121---2020-11-26)
2324
- [Fixed](#fixed-1)
2425
- [[v1.2.0] - (2020-11-26)](#v120---2020-11-26)
25-
- [Added](#added-3)
26+
- [Added](#added-4)
2627
- [Changed](#changed)
2728
- [[v1.1.0] - (2020-11-24)](#v110---2020-11-24)
28-
- [Added](#added-4)
29+
- [Added](#added-5)
2930
- [Changed](#changed-1)
3031
- [[v1.0.2] - (2020-11-23)](#v102---2020-11-23)
3132
- [Changed](#changed-2)
3233
- [[1.0.1] - (2020-11-23)](#101---2020-11-23)
33-
- [Added](#added-5)
34+
- [Added](#added-6)
3435
- [Fixed](#fixed-2)
3536
- [[1.0.0] - (2020-11-23)](#100---2020-11-23)
3637

@@ -40,6 +41,10 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/), and this
4041

4142
## [v1.4.0] - (2020-12-03)
4243

44+
### Added
45+
46+
- useHashScroll hook
47+
4348
---
4449

4550
## [v1.3.2] - (2020-12-02)

README.md

Lines changed: 39 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,10 @@ _Table Of Contents_
3737
- [Hooks](#hooks)
3838
- [useHashScroll](#usehashscroll)
3939
- [Summary](#summary-3)
40-
- [Demo](#demo-3)
4140
- [Params](#params)
4241
- [Example](#example-3)
4342
- [Reused Props](#reused-props)
44-
- [behavir](#behavir)
43+
- [behavior](#behavior)
4544
- [position](#position)
4645
- [requiredPathname](#requiredpathname)
4746
- [scrollFunc](#scrollfunc)
@@ -314,10 +313,47 @@ Creates a ref that scrolls to its assigned element when a specified hash is pres
314313

315314
`options`
316315

317-
-
316+
- Object specifying optional scroll options
317+
318+
- [`behavior`](#behavior)
319+
320+
- [`position`](#position)
321+
322+
- [`requiredPathname`](#requiredpathname)
323+
324+
- [`scrollFunc`](#scrollfunc)
318325

319326
#### Example
320327

328+
```javascript
329+
import React from "react";
330+
import { BrowserRouter } from "react-router-dom"; //Can use HashRouter or MemoryRouter as well
331+
import { useHashScroll } from "react-hash-scroll";
332+
333+
const App = () => {
334+
return (
335+
<BrowserRouter>
336+
<Example
337+
hash="#element1"
338+
options={{
339+
behavior: "smooth",
340+
}}
341+
>
342+
Element #1
343+
</Example>
344+
<Example hash="#element2">Element #2</Example>
345+
<Example hash="#element3">Element #3</Example>
346+
</BrowserRouter>
347+
);
348+
};
349+
350+
const Example = ({ children, hash, options }) => {
351+
const scrollRef = useHashScroll(hash, options); //options is optional
352+
353+
return <div ref={scrollRef}>Scrolled to when the hash is in the url</div>;
354+
};
355+
```
356+
321357
---
322358

323359
## Reused Props

docs/Hooks/useHashScroll.md

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,43 @@ Creates a ref that scrolls to its assigned element when a specified hash is pres
1414

1515
`options`
1616

17-
-
17+
- Object specifying optional scroll options
18+
19+
- [`behavior`](#behavior)
20+
21+
- [`position`](#position)
22+
23+
- [`requiredPathname`](#requiredpathname)
24+
25+
- [`scrollFunc`](#scrollfunc)
1826

1927
#### Example
28+
29+
```javascript
30+
import React from "react";
31+
import { BrowserRouter } from "react-router-dom"; //Can use HashRouter or MemoryRouter as well
32+
import { useHashScroll } from "react-hash-scroll";
33+
34+
const App = () => {
35+
return (
36+
<BrowserRouter>
37+
<Example
38+
hash="#element1"
39+
options={{
40+
behavior: "smooth",
41+
}}
42+
>
43+
Element #1
44+
</Example>
45+
<Example hash="#element2">Element #2</Example>
46+
<Example hash="#element3">Element #3</Example>
47+
</BrowserRouter>
48+
);
49+
};
50+
51+
const Example = ({ children, hash, options }) => {
52+
const scrollRef = useHashScroll(hash, options); //options is optional
53+
54+
return <div ref={scrollRef}>Scrolled to when the hash is in the url</div>;
55+
};
56+
```

0 commit comments

Comments
 (0)