ScrollMagic plugin for Vue.js
npm i vue-scrollmagic --save
import VueScrollmagic from 'vue-scrollmagic'
Vue.use(VueScrollmagic)// plugins/vue-scrollmagic.js
import VueScrollmagic from 'vue-scrollmagic'
Vue.use(VueScrollmagic)
// 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.
See ScrollMagic API and Example
Vue.use(VueScrollmagic, {
verical: true,
globalSceneOptions: {},
loglevel: 2,
refreshInterval: 100
})NOTE: Container is always a window.
// src/main.js
...
this.$scrollmagic.handleScrollTo = function (target) {
// some code
}
...import { TweenMax } from 'gsap'
import 'ScrollToPlugin'
...
this.$scrollmagic.handleScrollTo = function (target) {
TweenMax.to(window, 1.5, {
scrollTo: {
y: target,
autoKill: false
}
})
}
...| Name | Description |
|---|---|
| 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'
npm run serve
npm run build:demo
npm run build:lib
npm run lint