public
Created

Slide implementation zeptojs

  • Download Gist
Slider.js
JavaScript
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37
(function ($) {
$.fn.slideDown = function (duration) {
// get old position to restore it then
var position = this.css('position');
 
// show element if it is hidden (it is needed if display is none)
this.show();
 
// place it so it displays as usually but hidden
this.css({
position: 'absolute',
visibility: 'hidden'
});
 
// get naturally height
var height = this.height();
 
// set initial css for animation
this.css({
position: position,
visibility: 'visible',
overflow: 'hidden',
height: 0
});
 
// animate to gotten height
this.animate({
height: height
}, duration);
};
})(Zepto);
 
$(function () {
$('.slide-trigger').on('click', function () {
$('.slide').slideDown(2000);
});
});‚Äč

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.