vue-parallax-js

vue-parallax-js

vue-parallax-js

vue component for parallax effect on elements
no dependencies
lightweight
1.6 KB - minified
for Vue.js 2

Setup ~

install via npm
npm install --save vue-parallax-js
# or use yarn
# yarn add vue-parallax-js
			
using vue-parallax-js

in your main javascript file

// import Vue and vue-parallax-js
import Vue from 'vue'
import VueParallaxJs from 'vue-parallax-js'

// add vue-parallax-js to vue
Vue.use(VueParallaxJs)
			

Usage ~

in your templates you can now use the v-parallax directive.
<h1 v-parallax="0.2">vue-parallax-js</h1>

0 will appear static on the page (no effect)
1 will move along the page at the same speed as the scrolling
-1 will move upwards at the same speed as the scrolling
			

Options ~

when adding vue-parallax-js to Vue you can pass some options

Vue.use(VueParallaxJs, {option: value})
			
option
value-type
description
minWidth
integer
minumum window width for parallax to take effect

Modifiers ~

when using the v-parallax directive you can also pass some modifiers to configure the instance of vue-parallax-js

<h1 v-parallax.modifier="0.2">vue-parallax-js</h1>
// notice the . between "v-parallax" and the modifier
			
modifier
description
centerX
will add "transform: translateX(-50%)" along with the parallax positioning
absY
uses the window height instead of the element height for the calculations