Advertisement
Guest User

Untitled

a guest
Feb 21st, 2019
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.63 KB | None | 0 0
  1. if (!$el.hasClass('current'))
  2. {
  3.  
  4. // Animate other columns to smaller size
  5. $otherItems
  6. .removeClass('curCol')
  7. .stop(true)
  8. .animate({ 'width': $closedItemsWidth }, 500, 'linear')
  9. .css({"cursor":"pointer"});
  10.  
  11. // Animate current column to larger size
  12. $el
  13. .addClass('curCol')
  14. .stop(true)
  15. .delay(50)
  16. .animate({ 'width' : $openItemWidth }, 500, 'linear')
  17. .css({'cursor' : 'default'});
  18.  
  19. // Make sure the correct column is current
  20. $otherItems.removeClass('curCol');
  21. $el.addClass('curCol');
  22.  
  23.  
  24. }
  25.  
  26. // On click
  27. $grid.delegate('#grid > .col', 'click', function () {
  28. // Settings
  29. var $el = $(this);
  30. var $allItems = $grid.children('.col');
  31. var $otherItems = $allItems.not($el);
  32.  
  33. if (!$el.hasClass('current')) {
  34. // Animate other columns to smaller size
  35. $otherItems.stop(true)
  36. .removeClass('curCol')
  37. .animate({ 'width': $closedItemsWidth}, {step: function(prop, fx) {
  38. var cumWidth = 0;
  39. var item = this;
  40. $otherItems.each(function() {
  41. // haven't changed the width of this item yet, so use new width
  42. if (this == item) {
  43. cumWidth += fx.now;
  44. } else {
  45. cumWidth += parseFloat(this.style.width);
  46. }
  47. });
  48. $el.css({width: (100 - cumWidth) + '%'});
  49. }, duration: 500 }, 'linear')
  50. .css({"cursor":"pointer"});
  51.  
  52. // Animate current column to larger size
  53. $el.addClass('curCol').css({'cursor' : 'default'});
  54. }
  55. })​
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement