artemsemkin

Untitled

Oct 5th, 2020
633
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. const
  2.   $overlay = $slider.find('.slider-halfscreen__overlay'),
  3.   colors = [
  4.     'linear-gradient(90deg, rgba(255,0,0,0) 0%, rgba(255,0,0,1) 100%)', // slide 1
  5.     'linear-gradient(90deg, rgba(0,255,0,0) 0%, rgba(0,255,0,1) 100%)', // slide 2
  6.     'linear-gradient(90deg, rgba(0,0,255,0) 0%, rgba(0,0,255,1) 100%)', // slide 3
  7.   ];
  8.  
  9. // initial background overlay set for the 1st slide
  10. TweenMax.set($overlay, {
  11.   background: colors[0],
  12. });
  13.  
  14. // slider change event
  15. sliderImg.on('slideChange', function() {
  16.   const currentSlide = this.realIndex; // current slide index
  17.  
  18.   // if the color for the current slide exists in array
  19.   if (typeof colors[currentSlide] !== 'undefined') {
  20.     TweenMax.to($overlay, 1.2, {
  21.       background: colors[currentSlide],
  22.       overwrite: 'all'
  23.     });
  24.   }
  25. });
RAW Paste Data