Slide Toggle In Vanilla JavaScript – slideToggle.js

Category: Animation , Javascript | December 28, 2020
Author: ericbutler555
Views Total: 459 views
Official Page: Go to website
Last Update: December 28, 2020
License: MIT


Slide Toggle In Vanilla JavaScript – slideToggle.js


slideToggle.js is a vanilla JavaScript library to implement performant slideToggle, slideUp, and slideDown functionalities using requestAnimationFrame.

The goal of this library is to animate the height of matched elements similar to jQuery’s slideToggle method.

See Also:

How to use it:

1. Insert the minified version of the slideToggle.js and we’re ready to go.

<script src="slideToggle.min.js"></script>

2. Apply the slide toggle to an element.


3. Determine the duration of the slide animation. Default: 400.

slideToggle(element, 1000);
slideUp(element, 1000);
slideDown(element, 1000);

4. Trigger a function when the animation is completely finished.

slideToggle(element, 1000, function(){
  // do something
slideUp(element, 1000, function(){
  // do something
slideDown(element, 1000, function(){
  // do something

You Might Be Interested In:

Leave a Reply