| 9 | }; |
| 10 | |
| 11 | export class Intro { |
| 12 | constructor(el) { |
| 13 | // the SVG element |
| 14 | this.DOM = {el: el}; |
| 15 | // SVG texts |
| 16 | this.DOM.circleText = [...this.DOM.el.querySelectorAll('text.circles__text')]; |
| 17 | // total of texts |
| 18 | this.circleTextTotal = this.DOM.circleText.length; |
| 19 | // initial setudp |
| 20 | this.setup(); |
| 21 | } |
| 22 | setup() { |
| 23 | // need to set the transform origin in the center |
| 24 | gsap.set(this.DOM.circleText, { transformOrigin: '50% 50%' }); |
| 25 | // hide on start |
| 26 | gsap.set([this.DOM.circleText, DOM.content.children, DOM.frame.children], {opacity: 0}); |
| 27 | // don't allow to hover |
| 28 | gsap.set(DOM.enterCtrl, {pointerEvents: 'none'}); |
| 29 | |
| 30 | this.initEvents(); |
| 31 | } |
| 32 | initEvents() { |
| 33 | // click and hover events for the "enter" button: |
| 34 | this.enterMouseEnterEv = () => { |
| 35 | gsap.killTweensOf([DOM.enterBackground,this.DOM.circleText]); |
| 36 | |
| 37 | gsap.to(DOM.enterBackground, { |
| 38 | duration: 0.8, |
| 39 | ease: 'power4', |
| 40 | scale: 1.2, |
| 41 | opacity: 1 |
| 42 | }); |
| 43 | |
| 44 | gsap.to(this.DOM.circleText, { |
| 45 | duration: 4, |
| 46 | ease: 'power4', |
| 47 | rotate: '+=180', |
| 48 | stagger: { |
| 49 | amount: -0.3 |
| 50 | } |
| 51 | }); |
| 52 | }; |
| 53 | this.enterMouseLeaveEv = () => { |
| 54 | //gsap.killTweensOf(DOM.enterBackground); |
| 55 | gsap.to(DOM.enterBackground, { |
| 56 | duration: 0.8, |
| 57 | ease: 'power4', |
| 58 | scale: 1 |
| 59 | }); |
| 60 | }; |
| 61 | this.enterClickEv = () => this.enter(); |
| 62 | |
| 63 | DOM.enterCtrl.addEventListener('mouseenter', this.enterMouseEnterEv); |
| 64 | DOM.enterCtrl.addEventListener('mouseleave', this.enterMouseLeaveEv); |
| 65 | DOM.enterCtrl.addEventListener('click', this.enterClickEv); |
| 66 | } |
| 67 | // initial (intro) animation |
| 68 | start() { |
nothing calls this directly
no outgoing calls
no test coverage detected