Skip to main content

Parallax Image

Just import <ParallaxImage/> and set src.

import { ScrollContainer, ParallaxImage } from 'react-nice-scroll';
import 'react-nice-scroll/dist/styles.css';

const Index = () => {
return (
<ScrollContainer>
<section
style={{
height: '100vh',
display: 'flex',
alignItems: 'center',
justifyContent: 'center',
}}
>
<h1>Hello World!</h1>
</section>
<ParallaxImage src="https://reactjs.org/logo-og.png" />
<section
style={{
height: '100vh',
display: 'flex',
alignItems: 'center',
justifyContent: 'center',
}}
>
<h1>Hello World!!</h1>
</section>
</ScrollContainer>
);
};

export default Index;

parallaxImage Props

PropsValue TypeDefault Value
srcstringrequired
altstring |stringundefined
triggerElementgsap.DOMTarget | string | undefinedundefined
startstringtop bottom
endstringbottom top
axis'y' | 'x'y
fromPercentnumber-40
toPercentnumber40
containerHeightstring100vh
imageScalenumber1.2
imageObjectPositionstringcenter

parallaxImage Demo

Check demo.