Comments (4)
Hi! You can access instance of the LocomotiveScroll
with scroll
property.
const { potiah } = usePotiah()
potiah.scroll.destroy()
// anything you want to
from potiah.
Thank you, I'm able to access the instance but it looks that some methods are missing.
I'm working in a Nuxt 3 environment.
Here is the full list : https://scroll.locomotive.ca/docs/#/methods
It looks like start() and stop() methods for example are not available.
Or maybe I'm doing something wrong...
Also, It's weird I cannot run the scrollTo() method in the onMounted hook. But it works on click event... Here is my code:
<template>
<section>
<div class="section1">
<h1>Section 1</h1>
<button @click="potiah.scrollTo('.section2')">Click</button>
</div>
<div class="section2">
<h1>
Section 2
</h1>
</div>
</section>
</template>
<script lang="ts" setup>
import { usePotiah } from 'potiah'
const { potiah } = usePotiah()
onMounted(() => {
requestAnimationFrame(() => {
potiah.scrollTo(100)
});
})
</script>
<style scoped>
.section1 {
height: 100dvh;
background: green;
}
.section2 {
height: 100dvh;
background: red;
}
</style>
Thank you very much!
from potiah.
My bad - I missed the scroll
property access in the previous message (already fixed).
To access the LocomotiveScroll
instance, you need to run your code after scroll
is ready. scrollTo
will not work in onMounted
in your example because LocomotiveScroll
is not created yet (there is no guarantee even in raf
callback).
You can look there how to do it.
To clarify, all the methods you are looking for are on the scroll
property.
from potiah.
Perfect! Thank you so much it's works fine now and I understand better.
Really great job!
from potiah.
Related Issues (2)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from potiah.