{"id":13425804,"url":"https://github.com/michalsnik/aos","last_synced_at":"2025-05-12T03:51:48.721Z","repository":{"id":34844294,"uuid":"38836015","full_name":"michalsnik/aos","owner":"michalsnik","description":"Animate on scroll library","archived":false,"fork":false,"pushed_at":"2024-03-26T15:58:43.000Z","size":1465,"stargazers_count":27535,"open_issues_count":374,"forks_count":2635,"subscribers_count":316,"default_branch":"next","last_synced_at":"2025-05-12T02:32:06.496Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/michalsnik.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2015-07-09T17:49:00.000Z","updated_at":"2025-05-11T21:50:56.000Z","dependencies_parsed_at":"2024-04-09T21:47:36.813Z","dependency_job_id":"47da6eb3-dcfa-42ab-a069-6a95c1f64b3b","html_url":"https://github.com/michalsnik/aos","commit_stats":{"total_commits":219,"total_committers":22,"mean_commits":9.954545454545455,"dds":0.4657534246575342,"last_synced_commit":"329fb34f777034345f4d3f4def4dc3bcc300cc2e"},"previous_names":[],"tags_count":41,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/michalsnik%2Faos","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/michalsnik%2Faos/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/michalsnik%2Faos/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/michalsnik%2Faos/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/michalsnik","download_url":"https://codeload.github.com/michalsnik/aos/tar.gz/refs/heads/next","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253672614,"owners_count":21945477,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-07-31T00:01:19.274Z","updated_at":"2025-05-12T03:51:48.680Z","avatar_url":"https://github.com/michalsnik.png","language":"JavaScript","readme":"[![AOS - Animate on scroll library](https://s32.postimg.org/ktvt59hol/aos_header.png)](http://michalsnik.github.io/aos/)\n\n[![NPM version](https://img.shields.io/npm/v/aos/next.svg?style=flat)](https://npmjs.org/package/aos)\n[![NPM downloads](https://img.shields.io/npm/dm/aos.svg?style=flat)](https://npmjs.org/package/aos)\n[![Build Status](https://travis-ci.org/michalsnik/aos.svg?branch=master)](https://travis-ci.org/michalsnik/aos)\n[![Gitter](https://badges.gitter.im/michalsnik/aos.svg)](https://gitter.im/michalsnik/aos?utm_source=badge\u0026utm_medium=badge\u0026utm_campaign=pr-badge)\n\n[![Twitter Follow](https://img.shields.io/twitter/follow/michalsnik.svg?style=social)](https://twitter.com/michalsnik) [![Twitter URL](https://img.shields.io/twitter/url/http/shields.io.svg?style=social)](https://twitter.com/home?status=AOS%20-%20Animate%20on%20Scroll%20library%0Ahttps%3A//github.com/michalsnik/aos)\n\n## :exclamation::exclamation::exclamation: This is README for aos@next :exclamation::exclamation::exclamation:\n\nFor last stable release (v2) go [here](https://github.com/michalsnik/aos/tree/v2)\n\n---\n### 🚀 [Demo](http://michalsnik.github.io/aos/)\n\n### 🌟 Codepen Examples\n- [Different built-in animations](http://codepen.io/michalsnik/pen/WxNdvq)\n- [With anchor setting in use](http://codepen.io/michalsnik/pen/jrOYVO)\n- [With anchor-placement and different easings](http://codepen.io/michalsnik/pen/EyxoNm)\n- [With simple custom animations](http://codepen.io/michalsnik/pen/WxvNvE)\n\n👉 To get a better understanding how this actually works, I encourage you to check [my post on CSS-tricks](https://css-tricks.com/aos-css-driven-scroll-animation-library/).\n\n---\n\n## ⚙ Installation\n\n### Basic\n\nAdd styles in `\u003chead\u003e`:\n\n```html\n  \u003clink rel=\"stylesheet\" href=\"https://unpkg.com/aos@next/dist/aos.css\" /\u003e\n```\n\nAdd script right before closing `\u003c/body\u003e` tag, and initialize AOS:\n```html\n  \u003cscript src=\"https://unpkg.com/aos@next/dist/aos.js\"\u003e\u003c/script\u003e\n  \u003cscript\u003e\n    AOS.init();\n  \u003c/script\u003e\n```\n\n### Using package managers\n\nInstall `aos` package:\n* `yarn add aos@next`\n* or `npm install --save aos@next`\n\nImport script, styles and initialize AOS:\n```js\nimport AOS from 'aos';\nimport 'aos/dist/aos.css'; // You can also use \u003clink\u003e for styles\n// ..\nAOS.init();\n```\n\nIn order to make it work you'll have to make sure your build process has configured styles loader, and bundles it all correctly.\nIf you're using [Parcel](https://parceljs.org/) however, it will work out of the box as provided.\n\n---\n\n\n## 🤔 How to use it?\n\n### 1. Initialize AOS:\n\n```js\nAOS.init();\n\n// You can also pass an optional settings object\n// below listed default settings\nAOS.init({\n  // Global settings:\n  disable: false, // accepts following values: 'phone', 'tablet', 'mobile', boolean, expression or function\n  startEvent: 'DOMContentLoaded', // name of the event dispatched on the document, that AOS should initialize on\n  initClassName: 'aos-init', // class applied after initialization\n  animatedClassName: 'aos-animate', // class applied on animation\n  useClassNames: false, // if true, will add content of `data-aos` as classes on scroll\n  disableMutationObserver: false, // disables automatic mutations' detections (advanced)\n  debounceDelay: 50, // the delay on debounce used while resizing window (advanced)\n  throttleDelay: 99, // the delay on throttle used while scrolling the page (advanced)\n  \n\n  // Settings that can be overridden on per-element basis, by `data-aos-*` attributes:\n  offset: 120, // offset (in px) from the original trigger point\n  delay: 0, // values from 0 to 3000, with step 50ms\n  duration: 400, // values from 0 to 3000, with step 50ms\n  easing: 'ease', // default easing for AOS animations\n  once: false, // whether animation should happen only once - while scrolling down\n  mirror: false, // whether elements should animate out while scrolling past them\n  anchorPlacement: 'top-bottom', // defines which position of the element regarding to window should trigger the animation\n\n});\n```\n\n### 2. Set animation using `data-aos` attribute:\n\n```html\n  \u003cdiv data-aos=\"fade-in\"\u003e\u003c/div\u003e\n```\n\nAnd adjust behaviour by using `data-aos-*` attributes:\n```html\n  \u003cdiv\n    data-aos=\"fade-up\"\n    data-aos-offset=\"200\"\n    data-aos-delay=\"50\"\n    data-aos-duration=\"1000\"\n    data-aos-easing=\"ease-in-out\"\n    data-aos-mirror=\"true\"\n    data-aos-once=\"false\"\n    data-aos-anchor-placement=\"top-center\"\n  \u003e\n  \u003c/div\u003e\n```\n\n[See full list of all animations, easings and anchor placements](https://github.com/michalsnik/aos#animations)\n\n#### Anchor\n\nThere is also a setting that can be used only on per-element basis:\n* `data-aos-anchor` - element whose offset will be used to trigger animation instead of an actual one.\n\nExamples:\n```html\n\u003cdiv data-aos=\"fade-up\" data-aos-anchor=\".other-element\"\u003e\u003c/div\u003e\n```\n\nThis way you can trigger animation on one element, while you scroll to another - useful in animating fixed elements.\n\n---\n\n## API\n\nAOS object is exposed as a global variable, for now there are three methods available:\n\n  * `init` - initialize AOS\n  * `refresh` - recalculate all offsets and positions of elements (called on window resize)\n  * `refreshHard` - reinit array with AOS elements and trigger `refresh` (called on DOM changes that are related to `aos` elements)\n\nExample execution:\n```javascript\n  AOS.refresh();\n```\n\nBy default AOS is watching for DOM changes and if there are any new elements loaded asynchronously or when something is removed from DOM it calls `refreshHard` automatically. In browsers that don't support `MutationObserver` like IE you might need to call `AOS.refreshHard()` by yourself.\n\n`refresh` method is called on window resize and so on, as it doesn't require to build new store with AOS elements and should be as light as possible.\n\n---\n\n## JS Events\n\nAOS dispatches two events on document: `aos:in` and `aos:out` whenever any element animates in or out, so that you can do extra stuff in JS:\n```js\ndocument.addEventListener('aos:in', ({ detail }) =\u003e {\n  console.log('animated in', detail);\n});\n\ndocument.addEventListener('aos:out', ({ detail }) =\u003e {\n  console.log('animated out', detail);\n});\n```\n\nYou can also tell AOS to trigger custom event on specific element, by setting `data-aos-id` attribute:\n```html\n\u003cdiv data-aos=\"fade-in\" data-aos-id=\"super-duper\"\u003e\u003c/div\u003e\n```\n\nThen you'll be able to listen for two custom events then:\n- `aos:in:super-duper`\n- `aos:out:super-duper`\n\n---\n\n## Recipes:\n\n#### Adding custom animations:\nSometimes built-in animations are just not enough. Let's say you need one box to have different animation depending on resolution.\nHere's how you could do it:\n\n```css\n[data-aos=\"new-animation\"] {\n  opacity: 0;\n  transition-property: transform, opacity;\n\n  \u0026.aos-animate {\n    opacity: 1;\n  }\n\n  @media screen and (min-width: 768px) {\n    transform: translateX(100px);\n\n    \u0026.aos-animate {\n      transform: translateX(0);\n    }\n  }\n}\n```\nThen use it in HTML:\n```html\n\u003cdiv data-aos=\"new-animation\"\u003e\u003c/div\u003e\n```\nThe element will only animate opacity on mobile devices, but from 768px width it'll also slide from right to left.\n\n#### Adding custom easing:\nSimilar to animations you can add custom easings:\n```css\n[data-aos] {\n  body[data-aos-easing=\"new-easing\"] \u0026,\n  \u0026[data-aos][data-aos-easing=\"new-easing\"] {\n    transition-timing-function: cubic-bezier(.250, .250, .750, .750);\n  }\n}\n```\n\n#### Customizing default animations distance\nDefault distance for built-in animations is 100px. As long as you're using SCSS though, you can override it:\n```css\n$aos-distance: 200px; // It has to be above import\n@import 'node_modules/aos/src/sass/aos.scss';\n```\nYou have to however configure your build process to allow it to import styles from `node_modules` beforehand.\n\n#### Integrating external CSS animation library (e.g. Animate.css):\nUse `animatedClassName` to change default behaviour of AOS, to apply class names placed inside `data-aos` on scroll.\n\n```html\n\u003cdiv data-aos=\"fadeInUp\"\u003e\u003c/div\u003e\n```\n\n```js\nAOS.init({\n  useClassNames: true,\n  initClassName: false,\n  animatedClassName: 'animated',\n});\n```\n\nThe above element will get two classes: `animated` and `fadeInUp`. Using different combinations of the three above settings, you should be able to integrate any external CSS animation library.\n\nExternal libraries however don't care too much about animation state before the actual animation. So if you want those elements to be not visible before scrolling, you might need to add similar styles:\n```css\n[data-aos] {\n  visibility: hidden;\n}\n[data-aos].animated {\n  visibility: visible;\n}\n```\n\n---\n\n## Caveats:\n\n#### setting: `duration`, `delay`\n\nDuration and delay accept values from 50 to 3000, with step 50ms, it's because those are handled by css, and to not make css longer than it is already I implemented only a subset. I believe those should cover most cases.\n\nIf not, you can write simple CSS that will add another duration, for example:\n\n```css\n  body[data-aos-duration='4000'] [data-aos],\n  [data-aos][data-aos][data-aos-duration='4000'] {\n    transition-duration: 4000ms;\n  }\n```\nThis code will add 4000ms duration available for you to set on AOS elements, or to set as global duration while initializing AOS script.\nNotice that double `[data-aos][data-aos]` - it's not a mistake, it is a trick, to make individual settings more important than global, without need to write ugly \"!important\" there :)\n\nExample usage:\n```html\n  \u003cdiv data-aos=\"fade-in\" data-aos-duration=\"4000\"\u003e\u003c/div\u003e\n```\n\n---\n\n## Predefined options\n\n### Animations\n\n  * Fade animations:\n    * fade\n    * fade-up\n    * fade-down\n    * fade-left\n    * fade-right\n    * fade-up-right\n    * fade-up-left\n    * fade-down-right\n    * fade-down-left\n\n  * Flip animations:\n    * flip-up\n    * flip-down\n    * flip-left\n    * flip-right\n\n  * Slide animations:\n    * slide-up\n    * slide-down\n    * slide-left\n    * slide-right\n\n  * Zoom animations:\n    * zoom-in\n    * zoom-in-up\n    * zoom-in-down\n    * zoom-in-left\n    * zoom-in-right\n    * zoom-out\n    * zoom-out-up\n    * zoom-out-down\n    * zoom-out-left\n    * zoom-out-right\n\n### Anchor placements:\n\n  * top-bottom\n  * top-center\n  * top-top\n  * center-bottom\n  * center-center\n  * center-top\n  * bottom-bottom\n  * bottom-center\n  * bottom-top\n\n### Easing functions:\n\n  * linear\n  * ease\n  * ease-in\n  * ease-out\n  * ease-in-out\n  * ease-in-back\n  * ease-out-back\n  * ease-in-out-back\n  * ease-in-sine\n  * ease-out-sine\n  * ease-in-out-sine\n  * ease-in-quad\n  * ease-out-quad\n  * ease-in-out-quad\n  * ease-in-cubic\n  * ease-out-cubic\n  * ease-in-out-cubic\n  * ease-in-quart\n  * ease-out-quart\n  * ease-in-out-quart\n\n---\n\n## ❔Questions\n\nIf you found a bug, have a question or an idea, please check [AOS contribution guide](CONTRIBUTING.md) and don't hesitate to create new issues.\n","funding_links":[],"categories":["JavaScript","Uncategorized","Animate on scroll","CSS Animations","Web Development","Programming Languages","Programming","Table of Contents","Animations","what you need?"],"sub_categories":["Uncategorized","JavaScript","Scroll Animation Libraries"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmichalsnik%2Faos","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmichalsnik%2Faos","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmichalsnik%2Faos/lists"}