Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var sidebar = $('#sidebar').show(),
- sidebarButton = $('#sidebarButton', sidebar),
- w = sidebar.outerWidth();
- sidebar.css('left', '-' + w + 'px');
- sidebarButton.toggle (
- function() {
- sidebar.css('left', 0).show('slide', { easing: 'easeOutCubic' }, 1000, function() {
- sidebarButton.css('right', '-20px');
- });
- },
- function() {
- sidebar.animate({ left: '-' + w + 'px' }, 1000, 'easeOutCubic');
- sidebarButton.css('right', '-20px');
- }
- );
- }());
- <div id="sidebar">My sidebar</div>
- #sidebar {
- float:left;
- height:100%;
- position:fixed;
- background-color:#CCC;
- width:200px;
- display:none;
- }
- $(function(){
- toggle_sidebar();
- setTimeout(toggle_sidebar,3000);
- });
- function toggle_sidebar(){
- $('#sidebar').toggle('slide', { direction: 'left' }, 500);
- }
Add Comment
Please, Sign In to add comment