Slide Toggle In Vanilla JavaScript – slideToggle.js

Category: Animation , Javascript | February 15, 2022
Authorericbutler555
Last UpdateFebruary 15, 2022
LicenseMIT
Views4,094 views
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.

  • duration: Defaults to 40
  • callback: Optional
element.slideToggle(duration, callback);
element.slideUp(duration, callback);
element.slideDown(duration, callback);

Changelog:

v2.0.0 (02/15/2022)

  • move element from function param to object, to better mirror jquery

You Might Be Interested In:


Leave a Reply