vueport v0.1.6
VuePort
Vueport is a set of Vue JS data provider components designed to make it easy to add scroll effects to your Vue application.
Getting started
To add VuePort to your app simply run npm install vueport
. Once installed it
exposes two components that you can import.
import {
VueportPageScroll,
VueportElementPosition
} from "vueport";
Using VueportPageScroll
The VueportPageScroll
component uses scoped slots to provide the current
scroll position to your components. It can be used to build page progress
indicators, animations that depend on the overall scroll position, etc.
<vueport-page-scroll>
<div slot-scope="scrollPosition">
...
</div>
</vueport-page-scroll>
Exposed values
VueportPageScroll
makes the following values available to you:
scrollY
The current value ofwindow.scrollY
scrollHeight
The current value ofwindow.documentElement.scrollHeight
clientHeight
The current value ofwindow.documentElement.clientHeight
scrollableHeight
The height of the scrollable area of the document.scrollPcnt
The current percentage of the page that has been scrolled.
Using VueportElementPosition
The VueportElementPosition
component uses scoped slots to provide the current
position of the component it wraps relative to the device viewport.
<vueport-element-position>
<div slot-scope="elementPosition">
...
</div>
</vueport-element-position>
Exposed values
VueportElementPosition
makes the following values available to you:
boundingClientRect
The currentBoundingClientRect
for the componentvisible
Boolean. Whether the component is currently visible on the viewportfullyVisible
Boolean. Whether the component is currently fully visible on the viewportshown
Boolean. Whether the component has been shown. This is set totrue
when thenvisible
first becomestrue
and remains so for the rest of the component lifecycletopPcnt
The position of the top of the element relative to the top of the viewport as a percentagebottomPcnt
The position of the bottom of the element relative to the top of the viewport as a percentagecenter
The vertical position of the center of the element in pixelscenterPcnt
The position of the center of the element relative to the top of the viewport as a percentage
Coming Soon
VuePort is still a work in progress and is being added to all the time there will be more features added to both components and more components added in the near future. I will also be working on improving the documentation including a demo site built using VuePort and some examples of how to build cool scrolling animations using VuePort.
About the Author
Hi, I'm James O'Neill and I built VuePort. I'm a developer from Bristol, England.
If you want to know more about me you can check out my personal site or follow me on Twitter @jamesoneill83.