Created
November 28, 2012 11:46
-
-
Save sononix/4160673 to your computer and use it in GitHub Desktop.
Slide implementation zeptojs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment