Project 5 - Customized Scroll Animation

 About - 

     In this Blog, We will be designing Customized Scroll Animation. I am implementing this using simple Html, CSS and JavaScript , we are not using any frameworks.

 In this , I took some random content and images to display , You guys can take data you want and images and customize design patters, styles and color by making changes in Classes - img, body and box in style.css files.

You can find the source code for this below and I have attached the video of the output for reference. For images you can refer to my previous blog - 'https://bondasanathkumar.blogspot.com/2021/06/project-1-displaying-cards.html'.

index.html - 

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <link rel="stylesheet" href="style.css" />
    <title>Customized Scroll Animation</title>
  </head>
  <body>
    <h1>You have to Scroll to see the animation</h1>
    <div class="box"><h2>Some Unique monuments in World</h2></div>
    <div class="box"><h2>Christ the redeemer</h2></div>
    <div class="box"><img src="./Assets/Christ_the_redeemer.jpg" alt=""></div>
    <div class="box"><h2>colosseum</h2></div>
    <div class="box"><img src="./Assets/colosseum.jpg" alt=""></div>
    <div class="box"><h2>MachiPicchu</h2></div>
    <div class="box"><img src="./Assets/MachiPicchu.jpg" alt=""></div>
    <div class="box"><h2>Great Great wall of China</h2></div>
    <div class="box"><img src="./Assets/Great_wall_of_China.jpg" alt=""></div>
    <div class="box"><h2>StoneHenge</h2></div>
    <div class="box"><img src="./Assets/StoneHenge.jpg" alt=""></div>
    <div class="box"><h2>TajMahal</h2></div>
    <div class="box"><img src="./Assets/TajMahal.jpg" alt=""></div>
    <script src="script.js"></script>
  </body>
</html>

style.css -

@import url('https://fonts.googleapis.com/css2?family=Roboto:wght@400;700&display=swap');

* {
  box-sizingborder-box;
}

body {
  background-color: rgb(1177373);
  font-family'Roboto'sans-serif;
  displayflex;
  flex-directioncolumn;
  align-itemscenter;
  justify-contentcenter;
  margin0;
  overflow-xhidden;
}

h1 {
  margin10px;
  colorwhite;
}

.box {
  background-colorsteelblue;
  color#fff;
  displayflex;
  align-itemscenter;
  text-aligncenter;
  justify-contentcenter;
  width400px;
  height200px;
  margin10px;
  border-radius10px;
  box-shadow2px 4px 5px rgba(0000.3);
  transform: translateX(400%);
  transition: transform 0.4s ease;
}

.box:nth-of-type(even) {
  transform: translateX(-400%);
}

.box.show {
  transform: translateX(0);
}

.box h2 {
  font-size45px;
}

img{
  width400px;
  height200px;
  border-radius10px;
}

script.js -

const boxes = document.querySelectorAll('.box')

window.addEventListener('scroll', checkBoxes)

checkBoxes()

function checkBoxes() {
    const triggerBottom = window.innerHeight / 5 * 4

    boxes.forEach(box => {
        const boxTop = box.getBoundingClientRect().top

        if(boxTop < triggerBottom) {
            box.classList.add('show')
        } else {
            box.classList.remove('show')
        }
    })
}

OUTPUT :-


Comments

Popular posts from this blog

Project 3 - Customized Rotating Navigation

Project 2 - Progress Steps