Giter VIP home page Giter VIP logo

pawanhirumina / simple-aos-library Goto Github PK

View Code? Open in Web Editor NEW
0.0 2.0 0.0 6 KB

Introducing my personal AOS (Animate On Scroll) library, designed to effortlessly enhance the visual appeal of web pages by seamlessly incorporating scroll-triggered animations. AOS simplifies the integration of captivating animations, ensuring a delightful user experience as visitors navigate through the content.

CSS 17.16% JavaScript 39.96% HTML 42.88%
animation-js aos-animation css html html-css-javascript javascript library

simple-aos-library's Introduction

Simple AOS Library

A lightweight JavaScript library for adding scroll-triggered animations to your web projects. Easily integrate animated elements that come into view during scrolling.

Getting Started

Follow these steps to use the Simple AOS Library in your projects:

Step 1: Clone the Repository

  • Clone this repository to your local machine:
git clone https://github.com/Pawanhirumina/simple-aos-library.git

Step 2: Include Simple AOS Library Files

  • Copy the aos.js and aos.css files from the cloned repository to your project directory.

Step 3: Link Simple AOS Library Files in Your HTML

  • Include the Simple AOS Library files in the section of your HTML file:
<!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="aos.css">
    <script src="aos.js"></script>
    <title>Your Project with Simple AOS</title>
</head>
<body>

<!-- Your content here -->

<script>
    document.addEventListener('DOMContentLoaded', function () {
        const aosItems = document.querySelectorAll('.aos-item');

        function isElementInViewport(el) {
            const rect = el.getBoundingClientRect();
            return (
                rect.top >= 0 &&
                rect.bottom <= (window.innerHeight || document.documentElement.clientHeight)
            );
        }

        function handleScroll() {
            aosItems.forEach(item => {
                const aosType = item.getAttribute('data-aos');
                const hasAnimationClass = item.classList.contains(`aos-${aosType}`);

                if (isElementInViewport(item) && !hasAnimationClass) {
                    // Add the animation class
                    item.classList.add(`aos-${aosType}`);
                } else if (!isElementInViewport(item) && hasAnimationClass) {
                    // Remove the animation class if the element is no longer in view
                    item.classList.remove(`aos-${aosType}`);
                }
            });
        }

        window.addEventListener('scroll', handleScroll);
        window.addEventListener('resize', handleScroll);

        // Initial check on page load
        handleScroll();
    });
</script>

</body>
</html>

Step 4: Add Simple AOS Classes to Elements

Now, you can add the data-aos attribute to the HTML elements you want to animate:

<div class="aos-item" data-aos="fade-up">
    <h1>Welcome to Your Project</h1>
</div>

<div class="aos-item" data-aos="fade-left">
    <p>This is a simple example of using Simple AOS.</p>
</div>

<div class="aos-item" data-aos="fade-right">
    <p>Scroll down to see animations in action.</p>
</div>

Step 5: Customize and Run Your Project

Customize your animations by adjusting settings in the aos.init() function in the included JavaScript script. Open your HTML file in a web browser, and scroll down to see the animations in action.

That's it! You have successfully integrated the Simple AOS Library into your project. Happy scrolling and animating! ๐Ÿš€

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.