📋 محتويات الصفحة
📖 الوصف
Lenis هي مكتبة JavaScript لإنشاء smooth scrolling experience على الويب. توفر scroll behavior سلس مع inertia وcustomizable easing. من تطوير Darkroom (نفس الفريق وراء Locomotive Scroll). Lenis تُستخدم لإنشاء scroll experiences احترافية مع parallax effects وscroll-linked animations. خفيفة وتعمل مع جمي...
🎯 يستخدم في
مجالات استخدام هذه الأداة
Smooth scroll experiences
Parallax websites
Scroll-linked animations
Marketing websites
Creative websites
✨ المميزات
أبرز مميزات هذه الأداة
Smooth scrolling
Inertia physics
Lightweight (~10KB)
Framework-agnostic
Integrates مع GSAP/ScrollTrigger
Touch support
GPU-accelerated
TypeScript support
⚠️ العيوب
نقاط يجب مراعاتها
قد يسبب accessibility issues
قد يشعر بعض المستخدمين بعدم الراحة
Overhead إضافي
قد يتداخل مع scroll behavior الأصلي
🔄 البدائل
أدوات بديلة يمكنك استخدامها
💻 مثال على الاستخدام
كيفية استخدام هذه الأداة
import Lenis from 'lenis';
// Initialize
const lenis = new Lenis({
duration: 1.2,
easing: (t) => Math.min(1, 1.001 - Math.pow(2, -10 * t)),
direction: 'vertical',
gestureDirection: 'vertical',
smoothWheel: true,
wheelMultiplier: 1,
touchMultiplier: 2,
});
// Animation loop
function raf(time) {
lenis.raf(time);
requestAnimationFrame(raf);
}
requestAnimationFrame(raf);
// Scroll to position
lenis.scrollTo(0); // top
lenis.scrollTo(500); // 500px
lenis.scrollTo('#section'); // element
// Events
lenis.on('scroll', (e) => {
console.log(e.progress); // 0-1
console.log(e.velocity);
});
// GSAP integration
import { gsap } from 'gsap';
import { ScrollTrigger } from 'gsap/ScrollTrigger';
const lenis = new Lenis();
lenis.on('scroll', ScrollTrigger.update);
gsap.ticker.add((time) => lenis.raf(time * 1000));
// React
import { ReactLenis } from 'lenis/react';
function App() {
return (
<ReactLenis root options={{ duration: 1.2 }}>
<Content />
</ReactLenis>
);
}
// With GSAP ScrollTrigger
import { ReactLenis } from 'lenis/react';
import { gsap } from 'gsap';
import { ScrollTrigger } from 'gsap/ScrollTrigger';
function App() {
const lenisRef = useRef();
useEffect(() => {
function update(time) {
lenisRef.current.lenis.raf(time * 1000);
}
gsap.ticker.add(update);
return () => {
gsap.ticker.remove(update);
};
}, []);
return (
<ReactLenis ref={lenisRef} root>
<Content />
</ReactLenis>
);
}
📚 أدوات أخرى في Animation
قد يعجبك أيضاً
Anime.js
⭐مكتبة رسوم متحركة JavaScript (JavaScript Animation Library)
AutoAnimate
مكتبة رسوميات تلقائية بدون إعداد مسبق
Framer Motion
⭐مكتبة رسوم متحركة لـ React (React Animation Library)
GSAP
⭐مكتبة رسوم متحركة قوية (Powerful Animation Library)
Lottie
⭐مكتبة رسوم متحركة JSON-based (JSON Animation Library)
Motion One
مكتبة رسوميات خفيفة وعالية الأداء للويب