JavaScript chriscavs.github.io

Rallax.js – dead simple parallax scrolling  ↦

Vanilla JS. No dependencies. Even handles tricky situations like when conditions:

const parallax = rallax('.parallax')

// after reaching a certain position in the document, 
// increase the target's speed
parallax.when(
  () => window.scrollY > 400,
  () => parallax.changeSpeed(1)
)

// stop the parallax after a certain period of time
const startTime = new Date().getTime()

parallax.when(
  () => {
    const newTime = new Date().getTime()
    return newTime - startTime > 4000
  },
  () => parallax.stop()
)

Discussion

Sign in or Join to comment or subscribe

Player art
  0:00 / 0:00