MCPcopy Create free account
hub / github.com/codrops/OnScrollShapeMorph / fxIntro

Function fxIntro

js/index.js:537–592  ·  view source on GitHub ↗
(itemElement, options)

Source from the content-addressed store, hash-verified

535
536// First animation effect
537const fxIntro = (itemElement, options) => {
538 // Set up the animation settings
539 const settings = setupAnimationDefaults(itemElement, options);
540 // Select the elements to animate
541 const imageElement = itemElement.querySelector('.content__img');
542 const inner = imageElement.querySelector('.content__img-inner');
543
544 // Define and return the GSAP timeline for the animation
545 return gsap.timeline({
546 // Default easing for all animations in this timeline
547 defaults: {
548 ease: 'none'
549 },
550 // Event hook for when the timeline starts
551 onStart: () => {
552 // Apply perspective if specified
553 if ( settings.perspective ) {
554 gsap.set(imageElement, {
555 perspective: settings.perspective
556 });
557 }
558 },
559 // ScrollTrigger configuration for this timeline
560 scrollTrigger: settings.scrollTrigger
561 })
562 // The sequence of animation steps
563 .fromTo(imageElement, {
564 scale: 1,
565 xPercent: 0,
566 filter: 'brightness(100%)',
567 'clip-path': settings.clipPaths.step1.initial
568 }, {
569 scale: 0.5,
570 xPercent: -50,
571 'clip-path': settings.clipPaths.step1.final,
572 filter: 'brightness(500%)',
573 }, 0)
574 .to(inner, {
575 rotationY: -40,
576 scale: 1.4,
577 }, 0)
578 .to(imageElement, {
579 startAt: {
580 'clip-path': settings.clipPaths.step2.initial
581 },
582 scale: 0,
583 xPercent: -100,
584 'clip-path': settings.clipPaths.step2.final,
585 filter: 'brightness(100%)'
586 })
587 .to(inner, {
588 startAt: {rotationY: 40},
589 rotationY: 0,
590 scale: 1,
591 }, '<');
592}
593
594// Main function to apply scroll-triggered animations

Callers

nothing calls this directly

Calls 1

setupAnimationDefaultsFunction · 0.85

Tested by

no test coverage detected