You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on May 1, 2025. It is now read-only.
Copy file name to clipboardExpand all lines: README.md
+60-52Lines changed: 60 additions & 52 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -19,11 +19,6 @@ _Table Of Contents_
19
19
-[Why this one](#why-this-one)
20
20
-[Website](#website)
21
21
-[Components](#components)
22
-
-[Reused Props](#reused-props)
23
-
-[behavior](#behavior)
24
-
-[position](#position)
25
-
-[requiredPathname](#requiredpathname)
26
-
-[scrollFunc](#scrollfunc)
27
22
-[HashScroll](#hashscroll)
28
23
-[Summary](#summary)
29
24
-[Demo](#demo)
@@ -45,6 +40,11 @@ _Table Of Contents_
45
40
-[Demo](#demo-3)
46
41
-[Params](#params)
47
42
-[Example](#example-3)
43
+
-[Reused Props](#reused-props)
44
+
-[behavir](#behavir)
45
+
-[position](#position)
46
+
-[requiredPathname](#requiredpathname)
47
+
-[scrollFunc](#scrollfunc)
48
48
-[Contributing](#contributing)
49
49
-[More Info (Badges)](#more-info-badges)
50
50
@@ -104,49 +104,6 @@ The [website](https://react-hash-scroll.web.app/) compiles all the information a
104
104
105
105
**Note**: [react-router-dom](https://reactrouter.com/web/) is required as a peer dependency and all components must be wrapped in a [Router](https://reactrouter.com/web/api/BrowserRouter)
106
106
107
-
### Reused Props
108
-
109
-
Props that are used by multiple components
110
-
111
-
#### behavior
112
-
113
-
- The behavior of the scroll
114
-
- Note: not all browsers have implemented options for [scrollIntoView](https://developer.mozilla.org/en-US/docs/Web/API/Element/scrollIntoView) (which is what React Hash Scroll uses internally) - see [MDN](https://developer.mozilla.org/en-US/docs/Web/API/Element/scrollIntoView) and [Can I Use](https://caniuse.com/scrollintoview) - there is also a [browser polyfill](https://github.com/iamdustan/smoothscroll) for smooth scrolling which you can install separately so smooth scrolling will work in all browsers
115
-
- Type:
116
-
- "smooth": Smooth scroll (_Default_)
117
-
- "auto": Instant scroll
118
-
119
-
#### position
120
-
121
-
- The position of the element on the page after it is scrolled to
122
-
- Like [behavior](#behavior), some browsers don't support [scrollIntoView](https://developer.mozilla.org/en-US/docs/Web/API/Element/scrollIntoView) options yet, so this property may not work on all browsers.
123
-
- Type:
124
-
- "center": Element will scroll to center of page (_Default_)
125
-
- "end": Element will scroll to bottom of page
126
-
- "start": Element will scroll to top of page
127
-
- "nearest": Element will scroll to center/end/start depending on which one is closest
128
-
129
-
#### requiredPathname
130
-
131
-
- Only scroll on a specific pathname(s)
132
-
- Note: "/" matches to the website name with no pathname
133
-
-**Don't** end pathnames with "/" (Ex. "/test/")
134
-
- For example, to only scroll on:
135
-
-**/home/contact**: "/home/contact"
136
-
-**/docs** or **/features**: ["/docs", "/features"]
137
-
- Type: `string | string[]`
138
-
139
-
#### scrollFunc
140
-
141
-
- A custom scroll function that overrides the default [scrollIntoView](https://developer.mozilla.org/en-US/docs/Web/API/Element/scrollIntoView) function used by React Hash Scroll
142
-
- Parameters:
143
-
- ref: The ref object that contains the target element
144
-
-[behavior](#behavior): The defined scroll behavior for the element or the default behavior
145
-
-[position](#position): The defined scroll position for the element or the default position
@@ -162,9 +119,9 @@ Scrolls to child element when the specified hash is present in the url
162
119
`hash`
163
120
164
121
-**Required**
165
-
- Type: `string`
166
122
- The [hash](<https://www.oho.com/blog/explained-60-seconds-hash-symbols-urls-and-seo#:~:text=A%20hash%20sign%20(%23)%20in,specific%20subsection%20of%20that%20document.>) that should trigger scroll to the element
167
123
- Can include or exclude leading "#"
124
+
- Type: `string`
168
125
- Examples:
169
126
- "#example"
170
127
- "example"
@@ -180,9 +137,9 @@ Scrolls to child element when the specified hash is present in the url
180
137
`children`
181
138
182
139
-**Required**
183
-
- Type: `ReactElement`
184
140
- Must be a singular child (which **CANNOT** be text)
185
141
- Custom children must forward refs to a dom element
142
+
- Type: `ReactElement`
186
143
187
144
#### Example
188
145
@@ -347,14 +304,65 @@ const App = () => {
347
304
348
305
Creates a ref that scrolls to its assigned element when a specified hash is present in the url
349
306
350
-
#### Demo
351
-
352
307
#### Params
353
308
309
+
`hash`
310
+
311
+
-**Required**
312
+
- Type: `string`
313
+
- The hash that should trigger scroll
314
+
315
+
`options`
316
+
317
+
-
318
+
354
319
#### Example
355
320
356
321
---
357
322
323
+
## Reused Props
324
+
325
+
Props that are used by multiple components
326
+
327
+
### behavior
328
+
329
+
- The behavior of the scroll
330
+
- Note: not all browsers have implemented options for [scrollIntoView](https://developer.mozilla.org/en-US/docs/Web/API/Element/scrollIntoView) (which is what React Hash Scroll uses internally) - see [MDN](https://developer.mozilla.org/en-US/docs/Web/API/Element/scrollIntoView) and [Can I Use](https://caniuse.com/scrollintoview) - there is also a [browser polyfill](https://github.com/iamdustan/smoothscroll) for smooth scrolling which you can install separately so smooth scrolling will work in all browsers
331
+
- Type:
332
+
- "smooth": Smooth scroll (_Default_)
333
+
- "auto": Instant scroll
334
+
335
+
### position
336
+
337
+
- The position of the element on the page after it is scrolled to
338
+
- Like [behavior](#behavior), some browsers don't support [scrollIntoView](https://developer.mozilla.org/en-US/docs/Web/API/Element/scrollIntoView) options yet, so this property may not work on all browsers.
339
+
- Type:
340
+
- "center": Element will scroll to center of page (_Default_)
341
+
- "end": Element will scroll to bottom of page
342
+
- "start": Element will scroll to top of page
343
+
- "nearest": Element will scroll to center/end/start depending on which one is closest
344
+
345
+
### requiredPathname
346
+
347
+
- Only scroll on a specific pathname(s)
348
+
- Note: "/" matches to the website name with no pathname
349
+
-**Don't** end pathnames with "/" (Ex. "/test/")
350
+
- For example, to only scroll on:
351
+
-**/home/contact**: "/home/contact"
352
+
-**/docs** or **/features**: ["/docs", "/features"]
353
+
- Type: `string | string[]`
354
+
355
+
### scrollFunc
356
+
357
+
- A custom scroll function that overrides the default [scrollIntoView](https://developer.mozilla.org/en-US/docs/Web/API/Element/scrollIntoView) function used by React Hash Scroll
358
+
- Parameters:
359
+
- ref: The ref object that contains the target element
360
+
-[behavior](#behavior): The defined scroll behavior for the element or the default behavior
361
+
-[position](#position): The defined scroll position for the element or the default position
Copy file name to clipboardExpand all lines: docs/Components/HashScroll.md
+2-2Lines changed: 2 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -13,9 +13,9 @@ Scrolls to child element when the specified hash is present in the url
13
13
`hash`
14
14
15
15
-**Required**
16
-
- Type: `string`
17
16
- The [hash](<https://www.oho.com/blog/explained-60-seconds-hash-symbols-urls-and-seo#:~:text=A%20hash%20sign%20(%23)%20in,specific%20subsection%20of%20that%20document.>) that should trigger scroll to the element
18
17
- Can include or exclude leading "#"
18
+
- Type: `string`
19
19
- Examples:
20
20
- "#example"
21
21
- "example"
@@ -31,9 +31,9 @@ Scrolls to child element when the specified hash is present in the url
31
31
`children`
32
32
33
33
-**Required**
34
-
- Type: `ReactElement`
35
34
- Must be a singular child (which **CANNOT** be text)
36
35
- Custom children must forward refs to a dom element
Copy file name to clipboardExpand all lines: docs/ReusedProps.md
+5-5Lines changed: 5 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,16 +1,16 @@
1
-
###Reused Props
1
+
## Reused Props
2
2
3
3
Props that are used by multiple components
4
4
5
-
####behavior
5
+
### behavior
6
6
7
7
- The behavior of the scroll
8
8
- Note: not all browsers have implemented options for [scrollIntoView](https://developer.mozilla.org/en-US/docs/Web/API/Element/scrollIntoView) (which is what React Hash Scroll uses internally) - see [MDN](https://developer.mozilla.org/en-US/docs/Web/API/Element/scrollIntoView) and [Can I Use](https://caniuse.com/scrollintoview) - there is also a [browser polyfill](https://github.com/iamdustan/smoothscroll) for smooth scrolling which you can install separately so smooth scrolling will work in all browsers
9
9
- Type:
10
10
- "smooth": Smooth scroll (_Default_)
11
11
- "auto": Instant scroll
12
12
13
-
####position
13
+
### position
14
14
15
15
- The position of the element on the page after it is scrolled to
16
16
- Like [behavior](#behavior), some browsers don't support [scrollIntoView](https://developer.mozilla.org/en-US/docs/Web/API/Element/scrollIntoView) options yet, so this property may not work on all browsers.
@@ -20,7 +20,7 @@ Props that are used by multiple components
20
20
- "start": Element will scroll to top of page
21
21
- "nearest": Element will scroll to center/end/start depending on which one is closest
22
22
23
-
####requiredPathname
23
+
### requiredPathname
24
24
25
25
- Only scroll on a specific pathname(s)
26
26
- Note: "/" matches to the website name with no pathname
@@ -30,7 +30,7 @@ Props that are used by multiple components
30
30
-**/docs** or **/features**: ["/docs", "/features"]
31
31
- Type: `string | string[]`
32
32
33
-
####scrollFunc
33
+
### scrollFunc
34
34
35
35
- A custom scroll function that overrides the default [scrollIntoView](https://developer.mozilla.org/en-US/docs/Web/API/Element/scrollIntoView) function used by React Hash Scroll
0 commit comments