├── LICENSE
├── README.md
├── slideToggle.min.js
├── slideToggle.js
├── demo-styles.css
└── demo.html
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright 2020 Eric Butler
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
6 |
7 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
8 |
9 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
10 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # slideToggle in plain JavaScript
2 |
3 | Plain vanilla JavaScript version of jQuery's `slideToggle()`, `slideUp()`, and `slideDown()` functions. No dependencies!
4 |
5 | Check out [the demo page](https://ericbutler555.github.io/plain-js-slidetoggle/demo.html).
6 |
7 | ## How To Use
8 |
9 | element.slideToggle(duration, callback); // opens and closes an element
10 |
11 | element.slideUp(duration, callback); // closes/collapses an element
12 |
13 | element.slideDown(duration, callback); // opens/expands an element
14 |
15 | - element: *HTMLElement*. Required.
16 | - duration: *Number*. Optional. In milliseconds. Default 400.
17 | - callback: *Function*. Optional. Called once slide animation completes.
18 |
19 | That's it.
20 |
21 | ## Example Usage
22 |
23 |
24 |
Plain JavaScript version of the great slideToggle() function in jQuery. Slightly simplified.
37 |
Also includes slideUp() and slideDown().
38 |
39 |
Navigation Menu Demo
40 |
Click/tap the hamburger icon in the upper-right to open and close the navigation menu.
41 |
42 |
Accordion Demo
43 |
Click the different tabs to open a panel with more information. The other tabs will close as you open new ones, but you can adjust your own code if you want them to stay open.
44 |
45 |
46 |
47 |
Accordion Tab One
48 |
Description of accordion tab one
49 |
50 |
51 |
Accordion Tab Two
52 |
Some information about accordion tab two. Lorem ipsum dolor sit, amet consectetur adipisicing elit. Atque cum officiis minima illo fuga rem quae rerum veritatis reprehenderit laboriosam similique eos fugiat maiores quia, dolor accusamus, pariatur qui sint?
53 |
54 |
55 |
Accordion Tab Three
56 |
57 |
58 | Content for accordion tab number three
59 |
60 |
61 |
62 |
63 |
Like It?
64 |
Head over to the GitHub repo, click the star button and download for your own personal and commercial use.