Getting started â
What is Potiah? â
Potiah (pronounced /pot'jĘÉĶ/, means train in Ukrainian) is a thin Vue.js wrapper for precious Locomotive Scroll ð.
"It utilizes native
Vuefeatures such as components and composables to give maximum control overLocomotiveScrollAPI to developer and make it easier to integrate it into aVueapp."â ChatGPT
Core of the library:
- Potiah - ð.
- <ScrollView /> - wrapper for scrollable scene. It can be whole document or any container element inside the DOM.
- <ScrollComponent /> -
scroll elementwithin scroll scene. It gathers alldata-*attributes from Locomotive Scroll element. - useScroll - composable that returns current
Potiahinstance,scrollTofunction, refs with scroll data.
Before starting UNSTABLE â
The project is unstable and depends on Locomotive Scroll v5 beta. So there might be some breaking changes in the future unless stable (first major) version is released.
Best regards!
Installation â
Prerequisites â
- Vue version 3.3.0 or higher.
Bundler / package manager â
npm install potiahnpm install potiahpnpm add potiahpnpm add potiahyarn add potiahyarn add potiahDirect Download / CDN â
<script src="https://unpkg.com/potiah@1.0.0-alpha.1"></script><script src="https://unpkg.com/potiah@1.0.0-alpha.1"></script><script src="https://unpkg.com/potiah"></script><script src="https://unpkg.com/potiah"></script>Here unpkg is used as the CDN provider, but you can use any other CDN that serves npm packages. All top-level APIs are exposed as properties of the global Potiah object.
umd script inside use global Vue object, so don't forget to add vue as below:
<script src="https://unpkg.com/vue@3/dist/vue.global.js"></script>
<!-- Potiah could be place there --><script src="https://unpkg.com/vue@3/dist/vue.global.js"></script>
<!-- Potiah could be place there -->If you want to use library via native ES modules like Vuethere you can import it from CDN ES build using importmap (because dependencies externalized in ES Build):
<script type='importmap'>
{
"imports": {
"@studio-freight/lenis": "https://cdn.jsdelivr.net/gh/studio-freight/lenis@1.0.29/dist/lenis.modern.mjs",
"locomotive-scroll": "https://cdn.jsdelivr.net/npm/locomotive-scroll@beta/dist/locomotive-scroll.modern.mjs",
}
}
</script>
<script type="module">
import { createScroll } from 'https://unpkg.com/potiah@1.0.0-alpha.1/dist/potiah.mjs'
</script><script type='importmap'>
{
"imports": {
"@studio-freight/lenis": "https://cdn.jsdelivr.net/gh/studio-freight/lenis@1.0.29/dist/lenis.modern.mjs",
"locomotive-scroll": "https://cdn.jsdelivr.net/npm/locomotive-scroll@beta/dist/locomotive-scroll.modern.mjs",
}
}
</script>
<script type="module">
import { createScroll } from 'https://unpkg.com/potiah@1.0.0-alpha.1/dist/potiah.mjs'
</script>Or even import it natively:
<script type='importmap'>
{
"imports": {
"@studio-freight/lenis": "https://cdn.jsdelivr.net/gh/studio-freight/lenis@1.0.29/dist/lenis.modern.mjs",
"locomotive-scroll": "https://cdn.jsdelivr.net/npm/locomotive-scroll@beta/dist/locomotive-scroll.modern.mjs",
"potiah": "https://unpkg.com/potiah@1.0.0-alpha.1/dist/potiah.mjs"
}
}
</script>
<script type="module">
import { createScroll } from 'https://unpkg.com/potiah@1.0.0-alpha.1/dist/potiah.mjs'
import { createScroll } from 'potiah'
</script><script type='importmap'>
{
"imports": {
"@studio-freight/lenis": "https://cdn.jsdelivr.net/gh/studio-freight/lenis@1.0.29/dist/lenis.modern.mjs",
"locomotive-scroll": "https://cdn.jsdelivr.net/npm/locomotive-scroll@beta/dist/locomotive-scroll.modern.mjs",
"potiah": "https://unpkg.com/potiah@1.0.0-alpha.1/dist/potiah.mjs"
}
}
</script>
<script type="module">
import { createScroll } from 'https://unpkg.com/potiah@1.0.0-alpha.1/dist/potiah.mjs'
import { createScroll } from 'potiah'
</script>â Also note, that you need to load lenis styles from CDN too
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/locomotive-scroll@beta/bundled/locomotive-scroll.css"><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/locomotive-scroll@beta/bundled/locomotive-scroll.css">Setup ð ïļ â
If you use package manager import lenis styles in your code:
import 'locomotive-scroll/locomotive-scroll.css'import 'locomotive-scroll/locomotive-scroll.css'Create a scroll instance and pass it to the app as a plugin:
import { createApp } from 'vue'
import 'locomotive-scroll/locomotive-scroll.css' // if you install trough package manager
import { createPotiah } from 'potiah'
import App from './App.vue'
const app = createApp(App)
const potiah = createPotiah()
app.use(potiah)
app.mount('#app')import { createApp } from 'vue'
import 'locomotive-scroll/locomotive-scroll.css' // if you install trough package manager
import { createPotiah } from 'potiah'
import App from './App.vue'
const app = createApp(App)
const potiah = createPotiah()
app.use(potiah)
app.mount('#app')Creating instance arguments
createPotiah takes default options from LocomotiveScroll as argument and will be passed to every created LocomotiveScroll instance (every mounted ScrollView)