ScrollMagic plugin for Vue.js
Install
NPM
npm i vue-scrollmagic --save
Usage
mount with global
Vue
mount with nuxt.js/ssr
// plugins/vue-scrollmagic.jsVue // nuxt.config.js ... plugins: src: '~plugins/vue-scrollmagic.js' ssr: false ...
Once installed, the plugin add $scrollmagic to Vue.prototype and create global controller, to make him easily accessibles in every components.
Documentation
See ScrollMagic API and Example
Configure controller
Vue
NOTE: Container is always a window.
Set custom scollTo handle
// src/main.js...this$scrollmagic { // some code}...
Set custom scrollTo handle with GSAP animation
...this$scrollmagic { TweenMax}...
Methods
Name | Description |
---|---|
attachTo | Create scrollmagic controller to custom element. After creating the controller, you have access to your own Scrollmagic.Controller methods. |
scene | A Scene defines where the controller should react and how. |
addScene | Add one ore more scene(s) to the controller. |
destroy | Destroy the controller, all scenes and everything. |
removeScene | Remove one ore more scene(s) from the controller. |
scrollTo | Scroll to a numeric scroll offset, a DOM element, the start of a scene or provide an alternate method for |
update | Updates the controller params and calls updateScene on every scene, that is attached to the controller. |
updateScene | Update one ore more scene(s) according to the scroll position of the container. |
enabled | Get or Set the current enabled state of the controller. |
loglevel | Get or Set the current loglevel option value. |
scrollPos | Get the current scrollPosition or Set a new method to calculate it. When used as a setter this method prodes a |
info | Get all infos or one in particular |
NOTE: In package adds plugins 'gsap.animation' and 'debug.addIndicators'
Example
{ // Declare Scene const scene2 = this$scrollmagic // Declaration of animation and attaching to element // Helpful tags for orientation on the screen // Add Scene to controller this$scrollmagic const scene3 = this$scrollmagic // Attaching scrollmagic controller to element this$scrollmagic // Add scene to element scrollmagic controller this$refsscrollBox$scrollmagic}
Development
Compiles and hot-reloads
npm run serve
Compiles and minifies demo
npm run build:demo
Compiles and minifies library
npm run build:lib
Lints and fixes files
npm run lint