Guest User

Untitled

a guest
Jul 19th, 2018
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.57 KB | None | 0 0
  1. <ul>
  2. <li data-name="item1" class="nav">Item 1</li>
  3. <li data-name="item2" class="nav">Item 2</li>
  4. </ul>
  5.  
  6. $('.nav').live('click', function(){
  7. $('.nav').unbind('click');
  8.  
  9. var itemId = $(this).data('name');
  10.  
  11. if( itemId === 'item1') {
  12. $('#item1').animate({
  13. 'left' : '300'
  14. }, 300, function(){
  15. $('.nav').bind('click');
  16. });
  17. } else if( itemId === 'item2') {
  18. $('#item2').animate({
  19. 'left' : '300'
  20. }, 300, function(){
  21. $('.nav').bind('click');
  22. });
  23. }
  24. });
  25.  
  26. $('.nav').bind('click', function(el, ev) {
  27. clickme($(this), ev)
  28. });
  29.  
  30.  
  31. function clickme(obj, ev) {
  32. obj.unbind(ev);
  33. console.log(obj.css('margin-left'));
  34. var dest = 0;
  35. if (obj.css('margin-left') == '0px') {
  36. dest = '300';
  37. }
  38. obj.animate({
  39. 'margin-left': dest
  40. }, 3000, function() {
  41. obj.click(function() {
  42. clickme(obj)
  43. })
  44.  
  45. $('.nav').live('click', function(){
  46. $('.nav').unbind('click');
  47.  
  48. var itemId = $(this).data('name');
  49. var animated = $('.nav:animated').length;
  50. if( itemId === 'item1' && animated === 0) {
  51. $('#item1').animate({
  52. 'left' : '300'
  53. }, 300, function(){
  54. $('.nav').bind('click');
  55. });
  56. } else if( itemId === 'item2' && animated === 0) {
  57. $('#item2').animate({
  58. 'left' : '300'
  59. }, 300, function(){
  60. $('.nav').bind('click');
  61. });
  62. }
  63. });
  64.  
  65. if($(".nav:animated").length == 0){
  66. $('#item1').animate({
  67. .........
Add Comment
Please, Sign In to add comment