Travis build: 1768

This commit is contained in:
30secondsofcode
2018-03-03 12:44:13 +00:00
parent 6d3dc2119e
commit 875c0b2a12
3 changed files with 36 additions and 2 deletions

View File

@ -214,6 +214,7 @@ average(1, 2, 3);
* [`scrollToTop`](#scrolltotop)
* [`setStyle`](#setstyle)
* [`show`](#show)
* [`smoothScroll`](#smoothscroll)
* [`toggleClass`](#toggleclass)
* [`UUIDGeneratorBrowser`](#uuidgeneratorbrowser)
@ -3597,6 +3598,33 @@ show(...document.querySelectorAll('img')); // Shows all <img> elements on the pa
<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
Toggle a class for an element.

File diff suppressed because one or more lines are too long

View File

@ -8,7 +8,7 @@ Pass `{ behavior: 'smooth' }` to `.scrollIntoView` so it scrolls smoothly.
```js
const smoothScroll = element =>
document.querySelector(element).scrollIntoView({
behavior: 'smooth'
behavior: 'smooth'
});
```