Travis build: 1768
This commit is contained in:
28
README.md
28
README.md
@ -214,6 +214,7 @@ average(1, 2, 3);
|
|||||||
* [`scrollToTop`](#scrolltotop)
|
* [`scrollToTop`](#scrolltotop)
|
||||||
* [`setStyle`](#setstyle)
|
* [`setStyle`](#setstyle)
|
||||||
* [`show`](#show)
|
* [`show`](#show)
|
||||||
|
* [`smoothScroll`](#smoothscroll)
|
||||||
* [`toggleClass`](#toggleclass)
|
* [`toggleClass`](#toggleclass)
|
||||||
* [`UUIDGeneratorBrowser`](#uuidgeneratorbrowser)
|
* [`UUIDGeneratorBrowser`](#uuidgeneratorbrowser)
|
||||||
|
|
||||||
@ -3597,6 +3598,33 @@ show(...document.querySelectorAll('img')); // Shows all <img> elements on the pa
|
|||||||
<br>[⬆ Back to top](#table-of-contents)
|
<br>[⬆ Back to top](#table-of-contents)
|
||||||
|
|
||||||
|
|
||||||
|
### smoothScroll
|
||||||
|
|
||||||
|
Smoothly scrolls the element on which it's called into the visible area of the browser window.
|
||||||
|
|
||||||
|
Use `.scrollIntoView` method to scroll the element.
|
||||||
|
Pass `{ behavior: 'smooth' }` to `.scrollIntoView` so it scrolls smoothly.
|
||||||
|
|
||||||
|
```js
|
||||||
|
const smoothScroll = element =>
|
||||||
|
document.querySelector(element).scrollIntoView({
|
||||||
|
behavior: 'smooth'
|
||||||
|
});
|
||||||
|
```
|
||||||
|
|
||||||
|
<details>
|
||||||
|
<summary>Examples</summary>
|
||||||
|
|
||||||
|
```js
|
||||||
|
smoothScroll('#fooBar'); // scrolls smoothly to the element with the id fooBar
|
||||||
|
smoothScroll('.fooBar'); // scrolls smoothly to the first element with a class of fooBar
|
||||||
|
```
|
||||||
|
|
||||||
|
</details>
|
||||||
|
|
||||||
|
<br>[⬆ Back to top](#table-of-contents)
|
||||||
|
|
||||||
|
|
||||||
### toggleClass
|
### toggleClass
|
||||||
|
|
||||||
Toggle a class for an element.
|
Toggle a class for an element.
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
@ -8,7 +8,7 @@ Pass `{ behavior: 'smooth' }` to `.scrollIntoView` so it scrolls smoothly.
|
|||||||
```js
|
```js
|
||||||
const smoothScroll = element =>
|
const smoothScroll = element =>
|
||||||
document.querySelector(element).scrollIntoView({
|
document.querySelector(element).scrollIntoView({
|
||||||
behavior: 'smooth'
|
behavior: 'smooth'
|
||||||
});
|
});
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user