Guest User

Untitled

a guest
Dec 12th, 2018
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.84 KB | None | 0 0
  1. var menuMore = function() {
  2. var menu = $('.catalog-category__list'),
  3. menuWidth = menu.width(),
  4. menuItems = $('li', menu),
  5. itemsWidth = 0,
  6. moreBlock = $('.catalog-category__list-more'),
  7. moreBlockWidth = moreBlock.outerWidth(true),
  8. checkWidth = menuWidth - moreBlockWidth,
  9. moreList = $('.catalog-category-more__list'),
  10. breackpoint = 1680;
  11.  
  12. moreBlock.hide();
  13.  
  14. menuItems.each(function() {
  15. var $this = $(this);
  16.  
  17. menu.append($this);
  18.  
  19. if (windowWidth <= breackpoint) {
  20. moreBlock.hide();
  21. return;
  22. }
  23.  
  24. if ($this.hasClass('catalog-category__list-more')) return;
  25.  
  26. itemsWidth += $this.outerWidth(true);
  27.  
  28. if (itemsWidth < checkWidth) {
  29. menu.append($this);
  30. } else {
  31. moreList.append($this);
  32. moreBlock.show();
  33. }
  34. });
  35. }
Add Comment
Please, Sign In to add comment