Last active
March 9, 2023 02:09
-
-
Save julianrubisch/2d0674184b15506346868918cb00074f to your computer and use it in GitHub Desktop.
Simple stimulusjs parallax controller using https://simpleparallax.com/
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<img src="img/some-nice-photo.jpg" data-controller="parallax" /> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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') || '' | |
}) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
thanks!