Guest User

Untitled

a guest
Feb 17th, 2019
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.54 KB | None | 0 0
  1. // Переключение с карусели и назад в зависимотси от разрешения
  2. function owlToggle(className, opt, breakpoint) {
  3. if (window.innerWidth < breakpoint) {
  4. $(className).each(function() {
  5. $(this).addClass('owl-carousel owl-theme').owlCarousel(opt);
  6. });
  7. } else {
  8. $(className).removeClass('owl-carousel owl-theme').each(function() {
  9. $(this).trigger('destroy.owl.carousel').removeAttr('style');
  10. });
  11. }
  12. }
  13.  
  14. // Лента табов - пересчет драгдилера
  15. function reflowTabs(self, child, drag) {
  16. let parLen = self.outerWidth();
  17. let len = child.outerWidth();
  18.  
  19. if (len <= parLen) {
  20. if (!child.hasClass('disabled')) {
  21. drag.disable();
  22. }
  23. setTimeout(function() {
  24. child.attr('style', '');
  25. }, 10);
  26. } else {
  27. drag.enable();
  28. }
  29. }
  30.  
  31. $(function() {
  32. // Тэги - табы
  33. if ($('.tags__stage-outer[id^="tags"]').length) {
  34. $('.tags__stage-outer[id^="tags"]').each(function() {
  35. let self = $(this);
  36. let child = $(this).children();
  37. let drag = new Dragdealer($(this).attr('id'), {
  38. handleClass: 'tags__stage'
  39. });
  40.  
  41. reflowTabs(self, child, drag);
  42. $(window).on('resize orientationchange', () => reflowTabs(self, child, drag));
  43. });
  44. }
  45.  
  46. // Карусель карточек
  47. if ($('.info-blocks__slider').length) {
  48. let slider = $('.info-blocks__slider');
  49.  
  50. let options = {
  51. items: 1,
  52. dots: false,
  53. nav: false,
  54. loop: false,
  55. margin: 10
  56. }
  57.  
  58. owlToggle(slider, options, 768);
  59. $(window).on('resize orientationchange', () => owlToggle(slider, options, 768));
  60. }
  61. });
Add Comment
Please, Sign In to add comment