Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ add another resource

JavaScript

Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

Auto Save

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <link href="https://fonts.googleapis.com/css2?family=Moon+Dance&display=swap" rel="stylesheet">
<link href="https://fonts.googleapis.com/css2?family=Libre+Baskerville:ital,wght@0,400;0,700;1,400&family=Moon+Dance&display=swap" rel="stylesheet">

<section class="banner">
  <div>
    <div class="animating__circle animating__circle--one">
    </div>
    <div class="animating__circle animating__circle--two">
    </div>
    <div class="animating__circle animating__circle--three">
    </div>
  </div>
  <div class="banner__links">
    <a class="link banner__link hide-magnet" href="#">About</a>
    <a class="link banner__link hide-magnet" href="#">Blog</a>
    <a class="link banner__link hide-magnet" href="#">Contact</a>
    <a class="link banner__link hide-magnet" href="#">Who</a>
  </div>

  <div class="banner__text pos-center">
    <h1>BREGE</h1>
  </div>
  <div class="scroll hide">
    <span class="scroll__text">
      ( scroll )
    </span>
  </div>
  <div class="pos-center">
    <!--  index number only - should be in  revering order -->
    <div class="banner__anim-txt banner__img-number-wrap">
      <div class="banner__img-number">
        <h3 class="banner__img-name-txt">4</h3>
        <h3 class="banner__img-name-txt">3</h3>
        <h3 class="banner__img-name-txt">2</h3>
        <h3 class="banner__img-name-txt">1</h3>
      </div>
      <span> / 04</span>
    </div>
    <div class="banner__img-wrapper">
      <img class="banner__img img-size hide-magnet" src="https://res.cloudinary.com/dtmzwq2ua/image/upload/v1643726333/7_o8efvh.jpg" alt="img">
      <img class="banner__img img-size hide-magnet" src="https://res.cloudinary.com/dtmzwq2ua/image/upload/v1643726332/3_ltlmwj.jpg" alt="img">
      <img class="banner__img img-size hide-magnet" src="https://res.cloudinary.com/dtmzwq2ua/image/upload/v1643726332/5_lrsmve.jpg" alt="img">
      <img class="banner__img img-size hide-magnet" src="https://res.cloudinary.com/dtmzwq2ua/image/upload/v1643726189/4_vvvp8y.jpg" alt="img">
    </div>
    <div class="banner__img-name banner__anim-txt">
      <h3 class="banner__img-name-txt">Inte Le Chair</h3>
      <h3 class="banner__img-name-txt">Asto Da Pillow</h3>
      <h3 class="banner__img-name-txt">Paya Ja Miraro</h3>
      <h3 class="banner__img-name-txt">Rela Sa Tabelo</h3>
    </div>
  </div>
</section>
              
            
!

CSS

              
                @mixin respond($breakpoint) {
  @if $breakpoint == xxl {
    @media (max-width: 1400px) {
      @content;
    }
  }
}

.animating__circle {
  position: fixed;
  left: -40%;
  top: -75%;
  width: 150vh;
  height: 150vh;
  border: 1px solid #e5e5e5;
  border-radius: 50%;

  &--one {
    animation: animateOne 50s linear infinite alternate;
  }

  &--two {
    left: 15%;
    top: -25%;
    width: 350vh;
    height: 350vh;
    animation: animateTwo 50s linear infinite alternate;
  }

  &--three {
    left: auto;
    top: -40%;
    right: -20%;
    width: 120vh;
    height: 120vh;
    animation: animateThree 50s linear infinite alternate;
  }
}

@keyframes animateOne {
  from {
    transform: translateX(0);
  }

  to {
    transform: translateX(-200px) translateY(-400px) rotate(-360deg);
  }
}

@keyframes animateTwo {
  from {
    transform: translateX(0);
  }

  to {
    transform: translateX(500px) translateY(200px);
  }
}

@keyframes animateThree {
  from {
    transform: translateX(0);
  }

  to {
    transform: translateX(-600px) translateY(-600px) rotate(-360deg) scale(0.9);
  }
}

*,
*:before,
*:after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

.pos-center {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
}

.m-h-screen {
  min-height: 100vh;
}

.transition-3s {
  transition: 0.3s all;
}

a {
  font-family: "Libre Baskerville", serif;
  text-decoration: none;
  font-size: 24px;
  text-transform: uppercase;
  color: #666;
  opacity: 0.7;
  transition: 0.2s;

  @include respond(sm) {
    font-size: 22px;
  }

  &:hover {
    opacity: 1;
  }
}

.banner {
  height: 100vh;
  font-family: "Moon Dance", cursive;
  background: #fff;
  color: black;

  &__img-wrapper {
    height: 600px;
    width: 390px;
    position: relative;

    @include respond(xxl) {
      height: 470px;
      width: 320px;
    }
  }

  &__img {
    width: 100%;
    height: 100%;
    position: absolute;
    will-change: transform, z-index;
    transition: 0.3s ease-out;
  }

  &__img-name {
    bottom: -48px;
    letter-spacing: 2px;
  }

  &__img-number-wrap {
    top: -64px;
    display: flex;
    align-items: center;
    justify-content: center;

    @include respond(xxl) {
      top: -56px;
    }

    > span {
      letter-spacing: 2px;
    }

    .banner__img-number {
      position: relative;
      overflow: hidden;
      height: 20px;
      width: 12px;
      margin-right: 4px;
    }
  }

  &__anim-txt {
    position: absolute;
    left: 0;
    width: 100%;

    font-family: sans-serif;
    font-size: 14px;
    font-weight: 600;
    text-align: center;
    text-transform: uppercase;
  }

  &__img-name-txt {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    transition: 0.2s linear;
    opacity: 0;
    visibility: hidden;
    font-size: inherit;
    transform: translateY(12px);
  }

  .img-size {
    height: 570px;
    width: 370px;
    @include respond(xxl) {
      height: 470px;
      width: 320px;
    }
  }

  &__text {
    font-weight: normal;
    color: #333;
    font-size: 220px;
    letter-spacing: 72px;

    @include respond(xxl) {
      font-size: 180px;
    }
  }

  &__link {
    position: fixed;

    &:nth-child(1) {
      top: 10vh;
      left: 10vh;
    }

    &:nth-child(2) {
      top: 10vh;
      right: 10vh;
    }

    &:nth-child(3) {
      bottom: 10vh;
      right: 10vh;
    }

    &:nth-child(4) {
      bottom: 10vh;
      left: 10vh;
    }
  }
}

.scroll {
  position: fixed;
  transition: 0.4s cubic-bezier(0.165, 0.84, 0.44, 1);
  padding: 20px;
  z-index: 99;
  pointer-events: none;

  &__text {
    color: #333;
    font-size: 16px;
    font-weight: 700;
    white-space: nowrap;
    font-family: sans-serif;
  }
}

.fade-out {
  opacity: 0;
}

.fade-in {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
  height: auto;
}

              
            
!

JS

              
                // Design Based on this site https://grege-interieurs.com/
//========================================================================
//========================== VARIABLES ===================================
//========================================================================

const banner = document.querySelector(".banner");
const bannerImages = [...document.querySelectorAll(".banner__img")];
const bannerImageText = [...document.querySelectorAll(".banner__img-name > *")];
const bannerImageTextNumber = [
  ...document.querySelectorAll(".banner__img-number > *")
];
const magnetCursor = document.querySelector(".scroll");

let currentImageIndex = bannerImages.length - 1;
let wheelIndex = 0;
let reverse = false;

//========================================================================
//========================== MAIN CONTENT ================================
//========================================================================

const throwImage = () => {
  const animationDuration = 600;
  reverse ? currentImageIndex++ : currentImageIndex--;

  // at init - this is the last img in the array
  const firedImage = bannerImages.splice(
    reverse ? 0 : bannerImages.length - 1,
    1
  )[0]; // popping out last img

  if (bannerImages.length) {
    reverse ? bannerImages.push(firedImage) : bannerImages.unshift(firedImage);
  }

  handleTranslation(firedImage);

  // changing the z-index of all images right after throwing
  setTimeout(() => handleZindex(bannerImages), animationDuration / 3);
  // rotating the image at the time it stacks at the back
  setTimeout(() => handleTranslationBack(firedImage), 400);

  // preparing for the next throwing image - un-rotating
  const lastImage = bannerImages[reverse ? 0 : bannerImages.length - 1];
  const rotatingImage = bannerImages[bannerImages.length - 2];
  reverse
    ? setTimeout(() => handleRotation(rotatingImage), 100)
    : setTimeout(
        () => (lastImage.style.transform = "rotate(0) scale(1)"),
        animationDuration
      );

  if (currentImageIndex > bannerImages.length - 1) {
    currentImageIndex = 0;
  }

  if (currentImageIndex < 0) {
    currentImageIndex = bannerImages.length - 1;
  }

  handleTextAnimation(bannerImageText);
  handleTextAnimation(bannerImageTextNumber);
};

const handleTextAnimation = (arr) => {
  arr.forEach((item) => handleClass(item, "fade-in", "remove"));
  const currentImgTxt = imageText(currentImageIndex, arr);
  setTimeout(() => handleClass(currentImgTxt, "fade-in"), 200);
};

const handleMagnetCursor = (e) => {
  const { x, y } = e;
  magnetCursor.style.transform = `translate(${x}px, ${y}px)`;

  const ifMagnetIsToHide = e.target.classList.contains("hide-magnet")
    ? "add"
    : "remove";

  handleClass(magnetCursor, "fade-out", ifMagnetIsToHide);
  handleClass(magnetCursor, "hidden", "remove");
};

function throttle(func, limit) {
  let inThrottle;
  return function () {
    const args = arguments;
    const context = this;
    if (!inThrottle) {
      func.apply(context, args);
      inThrottle = true;
      setTimeout(() => (inThrottle = false), limit);
    }
  };
}
const throttledThrowImage = throttle(throwImage, 800);

window.addEventListener("mousemove", handleMagnetCursor);
banner.addEventListener("mousewheel", function (e) {
  const { deltaY } = e;
  wheelIndex++;
  deltaY < 0 ? (reverse = true) : (reverse = false);
  wheelIndex % 10 === 0 ? throttledThrowImage() : 0;
});

//========================================================================
//========================== UTILITIES ===================================
//========================================================================

function handleClass(node, className, type = "add") {
  node.classList[type](className);
}

const handleZindex = (arr) => arr.forEach((item, i) => (item.style.zIndex = i));

const handleTranslationBack = (img) => {
  img.style.transition = ".3s ease-out";
  img.style.transform = reverse
    ? `translateX(0) rotate(0deg)`
    : handleRotation(img);
  img.classList.remove("img-size");
};

const handleTranslation = (img) => {
  const translateValue =
    document.documentElement.clientWidth > 1400 ? -500 : -432;
  img.style.transform = `translateX(${translateValue}px) rotate(-16deg)`;
  img.classList.add("img-size");
  img.style.transition = ".3s ease";
};

const getRandomInt = (min, max) => {
  return Math.floor(Math.random() * (max - min + 1)) + min;
};

const handleRotation = (img) => {
  const min = getRandomInt(0, -8);
  const max = getRandomInt(8, 0);
  const randomDeg = getRandomInt(0, 1) ? min : max;
  img.style.transform = `rotate(${randomDeg}deg) scale(0.9)`;
};

const lastImageIndex = () => bannerImages.length - 1;

const imageText = (index, arr) => arr[index];

//========================================================================
//========================== AT - INIT ========================================
//========================================================================

bannerImages.forEach((img, index) => {
  // rotating all images except the current one
  if (index !== lastImageIndex()) handleRotation(img);
});

// showing the animating text
handleClass(imageText(lastImageIndex(), bannerImageText), "fade-in");
handleClass(imageText(lastImageIndex(), bannerImageTextNumber), "fade-in");

              
            
!
999px

Console