52
Rallax.js –dead simple parallax scrolling
source link: https://www.tuicool.com/articles/hit/fYVRryu
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
Rallax.js is a vanilla JS plugin that implements a dynamic parallax scrolling effect, without dependencies. See documentation .
Dead
Simple
Parallax
Scrolling
// example code for 'dead' blockconst dead = rallax('.dead')
dead.when(
() => window.scrollY > 750,
() => dead.stop()
).when(
() => window.scrollY < 750,
() => dead.start()
Explore a variety of options , including:
- Changing parallax speed
- Conditionally disabling and enabling the effect
- Compensating for mobile devices
// first use JS to take measurements, then apply stylesObject.assign(image.style, {
position: 'relative',
top: `${imageTop}px`,
left: `${imageLeft}px`,
height: `${imageHeight}px`,
width: `${imageWidth}px`
})
// add parallax using Rallax.js
const imageParallax = rallax(image, {speed})
Do it all effortlessly , quickly , and without jQuery .
See the full documentation on GitHub.
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK