not working correctly with Next.js 13.4.19
After upgrading project to newest release of nextjs everything stopped working. Not a single element with aos property got rendered (animation was not triggered).
Downgrading it back to 13.4.6 solved the issue
This is:
- Bug
Specifications
- AOS version: 2.3.4
- OS: Windows/linux
- Browser: chrome, edge, firefox
Expected Behavior
Animations should be triggered
Actual Behavior
not a single animation was triggered resulting in unusable website
Steps to Reproduce the Problem
- setup nextjs project and add aos
- Initialize aos with AOS.init
- add any animation to site element
- result - element is not visible on the site
Detailed Description
Possible Solution
NextJS version 13.5 was released short time ago. Does this behaviour still exist on the newest NextJS Version? In my opinion it could be a NextJS bug maybe?
I faced the same issue in next.js version 13+ and I did correctly the installation and It didn't work properly on my end!
I personally shifted from AOS to animejs which is a far better library to also a bit more complex ... maybe that would be a solution for both of you? :)
Keep in mind last commit was October 2018 ...
I fixed my issue please refer here https://github.com/shadcn-ui/ui/issues/1745
same issue in next.js 14.0.4
A solution that worked for me was adding a slight delay in initializing AOS (Next.js 14.1.0):
In my case the problem was that all the images were by default lazy loaded. To solve the issue I had to create an Image component that refreshed the AOS as soon as the image finished loading, and then I used this component across the app instead of the next/image one.
This is the piece of code that I used:
"use client";
import AOS from "aos";
import ImageComponent, { ImageProps } from "next/image";
export function Image(props: ImageProps) {
return (
<ImageComponent
{...props}
onLoad={() => AOS.refresh()}
/>
)
}