Untitled
unknown
plain_text
3 years ago
894 B
15
Indexable
import Lenis from "@studio-freight/lenis";
import { useFrame } from "~/composables/useFrame";
const lenis = ref(null);
export const createLenis = () => {
onMounted(() => {
if (!lenis.value) {
lenis.value = new Lenis({
duration: 1.2,
easing: (t) => Math.min(1, 1.001 - Math.pow(2, -10 * t)), // https://www.desmos.com/calculator/brs54l4xou
direction: "vertical", // vertical, horizontal
gestureDirection: "vertical", // vertical, horizontal, both
smooth: true,
mouseMultiplier: 1,
smoothTouch: false,
touchMultiplier: 2,
infinite: false,
});
}
});
useFrame(({ et }) => {
lenis.value.raf(et * 1000);
});
onUnmounted(() => {
if (lenis.value) {
lenis.value.destroy();
lenis.value = null;
}
});
return lenis;
};
export const useLenis = () => {
return lenis;
};
Editor is loading...