Advertisement
artemsemkin

Kinsey Template: slider content delayed animation

Jan 6th, 2022 (edited)
959
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. class SectionSliderProjectsFullscreen extends BaseComponent {
  2.   constructor({
  3.     target,
  4.     scope
  5.   }) {
  6.     super({
  7.       target,
  8.       scope
  9.     });
  10.   }
  11.  
  12.   set() {
  13.     this.$slider = this.$target.find('.js-slider-projects-fullscreen');
  14.  
  15.     this.textTransitionsEnabled = this.$target.find('.js-slider-projects-fullscreen__content').attr('data-transition') === 'text' || false;
  16.  
  17.     this.$firstSlide = this.textTransitionsEnabled ? this.$slider.find('.swiper-slide').eq(0) : this.$slider.find('.swiper-slide');
  18.     this.$firstHeading = this.$firstSlide.find('.slider__heading');
  19.     this.$firstSubheading = this.$firstSlide.find('.slider__subheading');
  20.     this.$firstDescription = this.$firstSlide.find('.slider__text');
  21.     this.$firstLine = this.$firstSlide.find('.post-meta__divider');
  22.     this.$firstLink = this.$firstSlide.find('.slider__wrapper-button');
  23.   }
  24.  
  25.   init() {
  26.     this.slider = new SliderProjectsFullscreen({
  27.       parent: this.$target,
  28.       target: this.$slider,
  29.       hasAnimation: this.hasAnimationScene()
  30.     });
  31.   }
  32.  
  33.   animateIn() {
  34.  
  35.     this.timeline
  36.       .animateText(this.$firstHeading, {
  37.         duration: 1.2,
  38.         delay: 1.0 // <--- Add this
  39.       }, '0')
  40.       .add([
  41.         gsap.effects.animateText(this.$firstSubheading, {
  42.           autoAlpha: 1,
  43.           duration: 1.2
  44.         }),
  45.         gsap.effects.animateHeadline(this.$firstLine)
  46.       ], '-=0.8')
  47.       .animateText(this.$firstDescription, {
  48.         duration: 1.2,
  49.         autoAlpha: 1,
  50.       }, '-=0.8')
  51.       .animateJump(this.$firstLink, '-=1.0');
  52.   }
  53.  
  54.   animateOut() {
  55.     const
  56.       $visibleSlide = this.$target.find('.swiper-slide-visible'),
  57.       $headline = $visibleSlide.find('.post-meta__divider'),
  58.       $link = $visibleSlide.find('.slider__wrapper-button');
  59.  
  60.     this.timelineOut.add([
  61.       gsap.effects.hideText($visibleSlide),
  62.       gsap.effects.hideHeadline($headline),
  63.       gsap.effects.hideJump($link),
  64.     ], '0');
  65.   }
  66. }
  67.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement