Git Product home page Git Product logo

react-animation-on-scroll's People

Contributors

huazhuangnan avatar metinarslanturk avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

react-animation-on-scroll's Issues

Add support for compatibility with OverlayScrollbars?

I'm using OverlayScrollbars (https://www.npmjs.com/package/overlayscrollbars-react) within my project to replace the scrollbar with an overlay rather than relying on the browser's built in scrollbars to prevent the page content 'shifting' when moving between pages that do/do not have overflow content.

Unfortunately, I assume due to how OverlayScrollbar works, it prevents this module from working. I have tested within Chrome Dev Tools that when I remove the classes applied to <html> and <body> etc by OverlayScrollbars, and remove overflow: hidden from ths styling, it returns the browser's normal scrollbar, and this module then works perfectly.

With OverlayScrollbars enabled, any items that load within the viewport shown when the page first loads (i.e. the top of the page before you do any scrolling), work perfectly and animate in - however when you scroll down, none of the other components detect the viewport change and animate in, and the first component doesn't animate out (again, I assume it can't detect the viewport change).

Do you think you'd be able to build in compatability with OverlayScrollbars at all? Your module is about the only actively maintained Animation On Scroll I can find for React, and I'd love to be able to use it!

Thanks :)

Put an anchor option

I think that it will be nice to have an anchor option, accepting css selector (e.g. #myApp), that will animati when the anchor element reach the offset. This will allow to do "group animations" in sequence

Doesn't work in Next.js

I installed the anime.css package and imported the CSS package to the file but it doesn't work, it stays hidden and does not reveal.
Next.js
image

Animation after content update?

First of all thank you for creating a awesome library.

I'm trying to animate text which is delivered through a API. Usually this has a small delay.
In the example below, the content is displayed instantly however I would like to animate it as soon as the content is ready.

import React from 'react';
import { AnimationOnScroll as AOS } from 'react-animation-on-scroll';

export default class App extends React.Component {
    constructor (props: any) {
        super(props);

        this.state = {
            content: ""
        }
    }

    componentDidMount () {
        setTimeout (() => {
            this.setState({ content: "Hello world!" });
        }, 5000);
    }

    render () {
        const { content } = this.state;

        return (
            <AOS animateIn="animate__fadeInDown" duration={1} initiallyVisible>
                <h1>{content}</h1>
            </AOS>
        );
    }
}

I tried using the flag initiallyVisible as you suggest this should be set with server side rendering. However the results were the same.

Changing the timeout from 5000 to 0 shows the animation properly.

Is there any way to achieve this?

Usage with Nextjs

Do you have any examples of this package being used with Nextjs? I'm coming across a window is not defined error.

Unhandled Runtime Error TypeError: Cannot read properties of null (reading 'clientHeight')

I'm using this library in my NextJS project

Then I got this error:

Unhandled Runtime Error
TypeError: Cannot read properties of null (reading 'clientHeight')

Call Stack
eval
node_modules/react-animation-on-scroll/dist/esm/components/AnimationOnScroll.js (94:0)
eval
node_modules/react-animation-on-scroll/dist/esm/components/AnimationOnScroll.js (155:0)
eval
node_modules/react-animation-on-scroll/dist/esm/components/AnimationOnScroll.js (177:0)
invokeFunc
node_modules/lodash.throttle/index.js (160:0)
leading-edge
node_modules/lodash.throttle/index.js (170:0)
debounced
node_modules/lodash.throttle/index.js (235:0)

Any idea?

Add an "as" prop to customize the returned element

Thanks for building this!
What do you think about being able to customize the returned element via something like an as prop?
I want to use this package within unordered lists to stagger the display of the list items, but wrapping the list items in the package's returned <div> creates invalid HTML.

I was thinking an as prop would be nice so you could maintain the proper markup in this situation.

Example:

<AnimationOnScroll
  animateIn="animate__fadeIn"
  as="li"
  duration={2}
  delay={index * 1000}
  animateOnce
>

You then add the as prop to the component:

as: Component

Default it to "div":

as = "div"

and then you change the component's return value to:

<Component
  ref={node}
  className={classNameProps ? `${classNameProps} ${classes}` : classes}
  style={Object.assign({}, style, styleProps)}
>
  {children}
</Component>

What do you think?

Horizontal page

I have horizontal scrolling page. width 100% and height 100vh. Animation work once on page first loading. and div which is not in viewport also load before I scroll to them.

How to fix it?

No animation if element is in the view

If the element is already in the viewport at first, the animation will not be triggered. Setting 'animatePreScroll' to true doesn't help. Can you check it?

I tried it in a newly built react project with react 18.2

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.