Advertisement
artemsemkin

Untitled

Sep 2nd, 2020 (edited)
1,622
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. class Grid extends BaseComponent {
  2.  
  3.   constructor({
  4.     target,
  5.     scope
  6.   }) {
  7.     super({
  8.       target,
  9.       scope
  10.     });
  11.     this.lazyInstance = new LazyLoad({
  12.       scope
  13.     });
  14.     this.$lazyImages = this.$target.find('img[data-src]');
  15.     this.isotopeInstance;
  16.     this._layoutImages();
  17.     this._layoutLazyImages();
  18.  
  19.     return this.isotopeInstance;
  20.   }
  21.  
  22.   run() {
  23.     this.isotopeInstance = this.$target.isotope({
  24.       itemSelector: '.js-grid__item',
  25.       columnWidth: '.js-grid__sizer',
  26.       percentPosition: true,
  27.       horizontalOrder: true,
  28.     });
  29.  
  30.     // *******************
  31.     // add this lines here
  32.     window.$window.one('arts/preloader/end arts/barba/transition/end', () => {
  33.       setTimeout(() => {
  34.         this.isotopeInstance.isotope('layout');
  35.       }, 300);
  36.     });
  37.     // *******************
  38.     // *******************
  39.   }
  40.  
  41.   _layoutImages() {
  42.     this.$target
  43.       .imagesLoaded()
  44.       .progress(() => {
  45.         this.isotopeInstance.isotope('layout');
  46.       })
  47.       .done(() => {
  48.         setTimeout(() => {
  49.           this.isotopeInstance.isotope('layout');
  50.         }, 300);
  51.       });
  52.   }
  53.  
  54.   _layoutLazyImages() {
  55.     this.lazyInstance.loadImages({
  56.       target: this.$lazyImages,
  57.       callback: () => {
  58.         this._layoutImages();
  59.       }
  60.     });
  61.   }
  62.  
  63. }
  64.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement