Skip to content

Instantly share code, notes, and snippets.

@julianrubisch
Last active March 9, 2023 02:09
Show Gist options
  • Save julianrubisch/2d0674184b15506346868918cb00074f to your computer and use it in GitHub Desktop.
Save julianrubisch/2d0674184b15506346868918cb00074f to your computer and use it in GitHub Desktop.
Simple stimulusjs parallax controller using https://simpleparallax.com/
<img src="img/some-nice-photo.jpg" data-controller="parallax" />
import { Controller } from 'stimulus'
import simpleParallax from 'simple-parallax-js'
export default class extends Controller {
connect () {
new simpleParallax(this.element, {
delay: this.data.get('delay') || 0,
orientation: this.data.get('orientation') || 'up',
scale: this.data.get('scale') || 1.3,
transition: this.data.get('transition') || 'cubic-bezier(0,0,0,1)',
overflow: this.data.get('overflow') === 'true',
customContainer: this.data.get('customContainer') || '',
customWrapper: this.data.get('customWrapper') || ''
})
}
}
@ordinz
Copy link

ordinz commented Oct 21, 2022

thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment