اصنع فيلم موشن UI ثنائي الأبعاد متكرر في حلقة مدته 10 ثوانٍ لتطبيقي. الصيغة: أفقي 16:9 بدقة 1920x1080 (ويصلح 1920x1078 أيضاً)، 60 إطاراً في الثانية، نحو 10.07 ث. ابنِه كلقطة واحدة متصلة: بلا قطعات، وكاميرا واحدة تتحرك عبر تخطيط واجهة واحد، وكرة بيضاء نقية تحمل القصة من عنصر إلى التالي. تقفز الكرة من مفتاح تبديل، وتسحب شريط تمرير إلى 100، وتطيح بثلاث بطاقات إشعارات، وتكتب رداً على لوحة مفاتيح، وتضغط return وتطير عائدة إلى المفتاح، فينساب الإطار الأخير إلى الأول. يقع كل تلامس على نبضة بإيقاع 120 BPM. المظهر: خلفية سوداء تقريباً مع شبكة نقاط خافتة، ولوحات بلون حبر عميق ولون مميز واحد وردي فاقع، بخط سانس نظيف واحد. الإحساس: نظيف وعصري وملموس، مع اصطدامات دقيقة ونوابض صغيرة. استخدم شعاري كأيقونة على كل بطاقة إشعار. تجنب القطعات، وأي لون مميز ثانٍ، والنوابض الكبيرة المتمايلة، والنص الضبابي عند السكون، والتعليق الصوتي، وضربات الطبول الإضافية.
البنية
الأزمنة بالثواني. شبكة الإيقاع 120 BPM والنبضة 1 عند 0.017 ث.
0.00-0.20، المفتاح. الكاميرا قريبة من المفتاح (نحو 4x) وطرف المؤشر على المقبض. النقر: يتمدد المقبض إلى نحو 53 x 36 وهو ينزلق إلى جهة التشغيل في 0.15 ث، ويمتزج لون المسار من الرمادي إلى الوردي على نابض مخمد حرجاً. الكاميرا تتحرك بالفعل نحو اليمين.
0.17-0.52. يقفز المقبض على هيئة الكرة البيضاء ويرسم قوساً نحو اليمين إلى بداية شريط التمرير. تتحرك الكاميرا وتبتعد لتتبعها، ويبتعد المؤشر منجرفاً إلى أسفل اليمين.
0.52-2.17، شريط التمرير. تتحول الكرة إلى المقبض وتُسحب نحو اليمين بحركة متباطئة. ينتهي التعبئة تحتها، ويتحول كل تدريج إلى الوردي عند تجاوزه. تظهر فقاعة القيمة من ذيلها وتعد من 0 إلى 100، وكل رقم يتغير يدخل خلال إطارين. تتبع الكاميرا المقبض (نحو 2.8x).
1.63-2.50. عند 100 تسقط الكرة من نهاية شريط التمرير. تميل الكاميرا إلى الأسفل وتكشف بطاقة الإشعار الأولى، "App name" / "Ideas in motion" (استبدلها باسم تطبيقك وسطرك).
2.52 و3.02 و3.52، الإشعارات. تهبط الكرة على البطاقات 1 و2 و3 بالتتابع. تقرأ البطاقة 2 "Live preview" / "Edit in words" والبطاقة 3 "App name" / "Ready to move?" (استبدلها بما يخصك: عناوين حتى نحو 12 حرفاً وأسطر حتى نحو 20). يصاحب كل هبوط تسطّح، وتنخفض البطاقة 5.5 وحدة وترتد بنابض. بعد 0.18 ث من كل ضربة تنزلق البطاقة إلى اليمين بحركة متسارعة، وهي تتلاشى وتتضبب. تنزل الكاميرا خطوة خطوة مع الكرة (نحو 2.6x).
4.00. تستيقظ الكبسولة: يتلاشى النص الإرشادي "Reply" خلال إطارين، ويظهر مؤشر كتابة وردي، ويقفز زر الإرسال الوردي المستدير بنابض.
4.02 و4.52 و5.02 و5.53 و6.03، الكتابة. عند كل نبضة تضرب الكرة مفتاحاً واحداً من الصف العلوي، فتهجّئ "try it" بالأحرف T وR وY وI وT (استبدلها بأحرفك الخمسة من الصف العلوي فقط). ينخفض المفتاح المضروب 4.5 وحدة ويسطع، ويتلاشى حرفه داخل الحقل خلال إطارين، ويتبعه المؤشر.
6.03-7.03. قفزة طويلة فوق أعلى الإطار إلى مفتاح return بينما تتحرك الكاميرا نحو اليمين.
7.03-7.77. تهبط الكرة على return. ينخفض المفتاح معها ويفتح لونه، ثم تتهيأ الكرة (تتسطح إلى الأسفل) وتنطلق. خارج المشهد يتحول الرد المكتوب إلى فقاعة رسالة وردية فوق الكبسولة، وتعرض الكبسولة نصها الإرشادي من جديد.
7.62-8.58. ابتعاد إلى التخطيط الكامل (نحو 1.4x) مع ضبابية حركة. يرتد شريط التمرير بنابض إلى 0 وفقاعته تعد تنازلياً، وترتد البطاقات الثلاث بنابض من اليمين واحدة تلو الأخرى (بفارق 0.12 ث)، وتطير الكرة إلى الأعلى واليسار فوق كل شيء.
8.58-8.80. اقتراب نحو المفتاح. تسقط الكرة فيه كمقبض على جهة الإيقاف، ويتلاشى المسار من الوردي عائداً إلى الرمادي.
9.17-10.07. يرتد المؤشر بنابض إلى المقبض وتبدأ الكاميرا حركتها، فينساب الإطار الأخير بسلاسة إلى الأول. يتكرر الفيلم في حلقة.
التكوين
الخلفية: أسود تقريباً #0D0B1E مع شبكة نقاط خافتة. عرض النقاط نحو 3 وحدات كل 28 وحدة، بلون أبيض لافندري #E9E4F2 بشفافية 11%، وتبقى حادة عند أي تكبير. اللوحات بلون حبر عميق:
بطاقات الإشعارات: #261664 مع ظل داكن ناعم أسفلها (نحو 0 9px 18px بنسبة 38% أسود).
مفاتيح لوحة المفاتيح: #302160 مع توهج خافت تحت كل مفتاح.
حقل الرد: #160B44 مع حد بسماكة 1.5 وحدة بلون #353244. عناصر التحكم (المفتاح في وضع الإيقاف، ومسار شريط التمرير، والتدريجات غير المتجاوزة، وفقاعة القيمة) بلون #353244. هناك لون مميز واحد، وردي فاقع #FB2D89، يُستخدم فقط للمفتاح في وضع التشغيل، وتعبئة شريط التمرير والتدريجات المتجاوزة، ومؤشر الكتابة، وزر الإرسال، وفقاعة الرسالة المرسلة. ألوان النص: الأبيض للعناوين وأحرف المفاتيح، و#CCC6E3 لأسطر الإشعارات، و#9D95C2 للتسميات الصغيرة ("now" و"return")، و#6B6385 للنص الإرشادي في الحقل. الكرة بيضاء نقية، 44 وحدة. المؤشر سهم أسود كلاسيكي بحد أبيض. الخط: Geist فقط. العناوين 600، والأسطر 400، وأحرف المفاتيح 500، وأرقام الفقاعة 700. الأحجام بوحدات العالم: العناوين 24، والأسطر 22.5، والتسميات 16-18، والأرقام 23. التخطيط (عالم واحد، بوحدات العالم، ومقبض المفتاح هو نقطة الأصل):
مفتاح بحجم 91 x 52 في أقصى اليسار.
مسار شريط تمرير من x 198 إلى 665، مع 11 تدريجاً تحته (كل 44.9 وحدة بدءاً من x 213) وفقاعة قيمة تركب فوق المقبض.
ثلاث بطاقات إشعارات بحجم 304 x 88 مكدسة تحت نهاية شريط التمرير (x 534، والحواف العلوية عند 208 و310 و413). لكل بطاقة شعاري كأيقونة مربعة مستديرة الزوايا بحجم 37.5 وحدة، وعنوان غليظ، وسطر، و"now" عند اليمين.
كبسولة رد بحجم 172 x 52 في أسفل اليسار مع النص الإرشادي "Reply".
تحت الكبسولة لوحة مفاتيح من صفين (QWERTYUIOP وASDFGHJKL) بمفاتيح 58 x 54 بخطوة 65.4 ومفتاح return طويل على شكل L عند اليمين.
التقنيات
الكاميرا هي مركز وتكبير على العالم الواحد: نحو 4x على المفتاح، و2.8x على امتداد شريط التمرير، و2.6x على البطاقات، و2.5x على لوحة المفاتيح، و1.4x عند أوسع لقطة. سهّل حركة التكبير في الفضاء اللوغاريتمي، واجعل المركز يتبع الكرة بنوابض ناعمة. تحمل حركات الكاميرا السريعة ضبابية حركة حقيقية، بأخذ عينات من المشهد على نحو نصف إطار. النص حاد تماماً عند السكون. تتسطح الكرة عند كل هبوط وتتهيأ (تتسطح إلى الأسفل) قبل الانطلاقات. وما تصطدم به يتفاعل بانخفاض صغير وارتداد بنابض: البطاقات 5.5 وحدة، والمفاتيح 4.5 وحدة، ومفتاح return ينخفض معها. يتمدد مقبض المفتاح أثناء انزلاقه، ويمتزج لون المسار على نابض مخمد حرجاً. تغادر البطاقات نحو اليمين بانزلاق متسارع وهي تتلاشى وتتضبب، وتعود على نوابض متدرجة بفارق 0.12 ث. تدخل الأرقام في فقاعة القيمة والحروف في الحقل أو تتلاشى داخلة خلال إطارين. اجعل كل النوابض صغيرة وكل الاصطدامات دقيقة. بلا قطعات أو انتقالات: كل شيء تحمله حركة الكاميرا الواحدة، وتتطابق النهاية مع البداية لحلقة سلسة.
الموسيقى
اصنع خلفية موسيقية إلكترونية UI-pop مرحة ومشرقة بإيقاع 120 BPM في مقام كبير، بطول الفيلم تماماً، مع نبضاتها على شبكة الفيلم (النبضة 1 عند 0.017 ث).
أول 1.8 ث: أربيجيو منقور شبيه بالماريمبا وحده.
بعد ذلك: طبلة باص ناعمة أربع ضربات في الميزان، وباص سفلي، وطقطقات واضحة على الضربة الضعيفة.
من ضغطة return عند 7.03 ث: تصبح الخلفية مكتومة (مرشح تمرير منخفض، وأخفض ببضعة ديسيبل) طوال الابتعاد.
عند 8.78 ث: تنفتح من جديد عندما تهبط الكرة في المفتاح، ثم تخف تدريجياً نحو الحلقة. المزج عند نحو -14 LUFS، والذروة الحقيقية دون -1 dBTP.
الصوت
ضع مؤثراً صوتياً على كل تلامس، بلا طبول إضافية:
المفتاح: نقرة حادة (0.02)، ثم فرقعة فقاعية عندما يغادر المقبض (0.17).
شريط التمرير: طرقة خشبية ناعمة عند هبوط الكرة (0.52)، وتكة صاعدة هادئة لكل تدريج يتجاوزه المقبض، ونغمة ماريمبا من نغمتين عند 100 (2.13).
البطاقات: طرقات خشبية مجوفة تعلو درجة صوتها على البطاقات الثلاث (2.52 و3.02 و3.52)، مع صوت سووش هامس عند انزلاق كل منها.
الرد: رنة ناعمة عندما يستيقظ الحقل (4.0) ونقرات مفاتيح جافة عند كل ضربة.
Return: صوت whoosh على القفزة الطويلة (ذروته عند 6.55)، وطرقة أثقل على return (7.03)، وفرقعة عند إرسال الرسالة (7.12)، وصوت صاعد قصير نحو الانطلاق (7.77).
الابتعاد: صوت whoosh كاسح طويل (ذروته عند 8.05) وهمسات خافتة عند عودة البطاقات.
النهاية: رنين جرس مشرق ونقرة عندما تهبط الكرة في المفتاح (8.78). بلا تعليق صوتي.
المراجع
أفلام متقنة لتفاعلات UI الدقيقة عند إطلاق التطبيقات. تخيّل ريل منتج متكرراً بأسلوب Dribbble تعزف فيه كرة مرتدة على كل عنصر تحكم، مصوراً بحركة كاميرا واحدة متصلة عبر واجهة داكنة مسطحة.
ما يلزم تجهيزه
أيقونة تطبيقك أو شعاره، مربع الشكل، ويفضل على خلفية شفافة؛ وهو الأيقونة على بطاقات الإشعارات الثلاث كلها.
التقنيات في هذا الفيديو
حيل الموشن ديزاين التي بُني منها الفيديو، ولكل منها كود مستقل تفتحه في المتصفح أو تعطيه لوكيلك.
عند 0:08 من الفيديو0:08
الكاميرا
كاميرا عالم واحد بتكبير في الفضاء اللوغاريتمي وشبكة نقاط في فضاء الشاشة
يوجد كل جزء من الواجهة مرة واحدة في عالم واحد (بوحدات لا بكسلات) وتتحرك كاميرا واحدة عبره: مركز وتكبير، يُطبَّقان بصيغة translate(960 - x*z, 540 - y*z) scale(z) على العالم. بين المحطات يتحرك المركز بمنحنى power3.inOut ويُستكمل التكبير في الفضاء اللوغاريتمي، فتبدو لقطة قريبة بتكبير 4x ولقطة واسعة بالسرعة نفسها. تُرسم شبكة النقاط على canvas في فضاء الشاشة من الكاميرا نفسها في كل إطار (خطوة 28 وحدة ونقاط 1.5 وحدة)، فتبقى حادة عند أي تكبير.
متى تُستخدمقصة منتج أو واجهة تُروى في لقطة واحدة متصلة بدل القطعات: كل لقطة قريبة هي حركة عبر التخطيط نفسه.
عرض الكود
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>كاميرا عالم واحد بتكبير في الفضاء اللوغاريتمي وشبكة نقاط في فضاء الشاشة</title>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/gsap.min.js"></script>
<style>
html, body { margin: 0; height: 100%; overflow: hidden; background: #000; }
#root { position: relative; overflow: hidden; transform-origin: 0 0; }
</style>
<style>
@import url("https://fonts.googleapis.com/css2?family=Geist:wght@400;500;600;700&display=swap");
#root { position: relative; width: 100%; height: 100%; overflow: hidden; background: #0d0b1e; font-family: "Geist", sans-serif; color: #fff; }
.stage { position: absolute; left: 0; top: 0; width: 1px; height: 1px; transform-origin: 0 0; }
.stage > * { position: absolute; }
#grid { position: absolute; inset: 0; }
.sw { left: -27px; top: -26px; width: 92px; height: 52px; border-radius: 26px; background: #fb2d89; }
.track { left: 198px; top: -3.5px; width: 467px; height: 7px; border-radius: 3.5px; background: #353244; }
.card { left: 534px; width: 304px; height: 88px; padding-left: 24px; border-radius: 14px; background: #261664; font: 600 24px/88px "Geist", sans-serif; box-shadow: 0 9px 18px rgba(0, 0, 0, 0.38); }
.keys { left: 490px; top: 516px; width: 648px; height: 54px; background: repeating-linear-gradient(90deg, #302160 0 58px, transparent 58px 65.4px); }
</style>
</head>
<body>
<div id="root" data-composition-id="main" data-start="0" data-duration="6" data-width="1920" data-height="1080">
<canvas id="grid" class="clip" data-start="0" data-duration="6" width="1920" height="1080"></canvas>
<div id="world" class="stage clip" data-start="0" data-duration="6">
<div class="sw"></div><div class="track"></div>
<div class="card" style="top:208px">"First card"</div><div class="card" style="top:310px">"Second card"</div>
<div class="card" style="top:413px">"Third card"</div><div class="keys"></div>
</div>
</div>
<script>
// The composition at its own size, hidden, until its timeline plays: the code
// measures its layout as the renderer lays it out, not shrunk to the window.
(() => {
const root = document.getElementById('root');
if (!root) return;
Object.assign(root.style, {
width: (Number(root.dataset.width) || 1080) + 'px',
height: (Number(root.dataset.height) || 1920) + 'px',
visibility: 'hidden',
});
})();
</script>
<script>
// camera stations in world units: centre x, centre y and zoom
const STATIONS = [
{ t: 0.0, x: 70, y: 11, z: 3.95 }, // the switch, close
{ t: 1.4, x: 600, y: 11, z: 2.83 }, // along the track
{ t: 2.6, x: 690, y: 320, z: 2.58 }, // down to the cards
{ t: 3.8, x: 640, y: 440, z: 2.49 }, // the keys
{ t: 4.9, x: 420, y: 160, z: 1.38 }, // pull back: the whole world
{ t: 6.0, x: 70, y: 11, z: 3.95 }, // back to the first frame, so it loops
];
const ease = gsap.parseEase("power3.inOut");
const world = document.getElementById("world"), g = document.getElementById("grid").getContext("2d");
function camAt(t) {
let i = 0; while (i < STATIONS.length - 2 && t > STATIONS[i + 1].t) i++;
const a = STATIONS[i], b = STATIONS[i + 1], u = ease(Math.min(1, Math.max(0, (t - a.t) / (b.t - a.t))));
return { x: a.x + (b.x - a.x) * u, y: a.y + (b.y - a.y) * u, z: Math.exp(Math.log(a.z) + (Math.log(b.z) - Math.log(a.z)) * u) };
}
function draw(t) {
const c = camAt(t);
world.style.transform = `translate(${960 - c.x * c.z}px, ${540 - c.y * c.z}px) scale(${c.z})`;
g.clearRect(0, 0, 1920, 1080); g.fillStyle = "rgba(233,228,242,0.11)"; g.beginPath();
const G = 28, r = Math.max(0.8, 1.5 * c.z); // grid pitch and dot radius in world units
for (let wy = Math.floor((c.y - 540 / c.z) / G) * G; wy <= c.y + 540 / c.z + G; wy += G)
for (let wx = Math.floor((c.x - 960 / c.z) / G) * G; wx <= c.x + 960 / c.z + G; wx += G) {
const sx = (wx - c.x) * c.z + 960, sy = (wy - c.y) * c.z + 540; g.moveTo(sx + r, sy); g.arc(sx, sy, r, 0, Math.PI * 2);
}
g.fill();
}
const tl = gsap.timeline({ paused: true });
const clock = { t: 0 };
tl.to(clock, { t: 6, duration: 6, ease: "none", onUpdate: () => draw(clock.t) }, 0);
draw(0);
window.__timelines = window.__timelines || {};
window.__timelines["main"] = tl;
</script>
<script type="module">
// Once the code registers its timeline, which some do only after their fonts
// load, fit the composition to the window and play the timeline on a loop.
const root = document.getElementById('root');
const width = Number(root?.dataset.width) || 1080;
const height = Number(root?.dataset.height) || 1920;
const fit = () => {
if (!root) return;
const scale = Math.min(innerWidth / width, innerHeight / height);
Object.assign(root.style, {
width: width + 'px',
height: height + 'px',
transform: 'scale(' + scale + ')',
marginLeft: (innerWidth - width * scale) / 2 + 'px',
marginTop: (innerHeight - height * scale) / 2 + 'px',
});
};
const since = performance.now();
const play = () => {
const timeline = window.__timelines?.main;
if (!timeline && performance.now() - since < 5000) {
// Not a frame callback: those wait while the page is in the background.
setTimeout(play, 30);
return;
}
fit();
addEventListener('resize', fit);
if (root) root.style.visibility = '';
timeline?.repeat(-1).play(0);
};
play();
</script>
</body>
</html>
عند 0:02 من الفيديو0:02
أشكال
تمرير الكرة: أقواس بتوقيت الإيقاع مع انضغاط عند كل هبوط
تنتقل كرة بيضاء بين الأهداف في أوقات إيقاع ثابتة (هنا كل 0.5 ث): كل قفزة قطع مكافئ فوق الخط المستقيم بين نقطتي هبوط (x خطي مع الزمن، وارتفاع 95 وحدة في منتصف القفزة)، فيُحسب أي إطار من الزمن وحده. عند الهبوط تنضغط إلى نحو 1.3 x 0.77 لثلاثة إطارات ثم تستعيد شكلها؛ وفي الطيران السريع تتمدد 5% على امتداد السقوط. والسطح الذي تصطدم به ينخفض 5.5 وحدة ويرتد خلال 11 إطارًا.
متى تُستخدمربط لحظات الواجهة بجسم مادي واحد، بحيث يُعرض كل انتقال كمسار لا كقطع.
عرض الكود
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>تمرير الكرة: أقواس بتوقيت الإيقاع مع انضغاط عند كل هبوط</title>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/gsap.min.js"></script>
<style>
html, body { margin: 0; height: 100%; overflow: hidden; background: #000; }
#root { position: relative; overflow: hidden; transform-origin: 0 0; }
</style>
<style>
@import url("https://fonts.googleapis.com/css2?family=Geist:wght@400;500;600;700&display=swap");
#root { position: relative; width: 100%; height: 100%; overflow: hidden; background: #0d0b1e; font-family: "Geist", sans-serif; color: #fff; }
.stage { position: absolute; left: 0; top: 0; width: 1px; height: 1px; transform-origin: 0 0; }
.stage > * { position: absolute; }
.card { width: 304px; height: 88px; border-radius: 14px; background: #261664; box-shadow: 0 9px 18px rgba(0, 0, 0, 0.38); }
.ball { left: 0; top: 0; width: 44px; height: 44px; border-radius: 50%; background: #fff; }
</style>
</head>
<body>
<div id="root" data-composition-id="main" data-start="0" data-duration="3" data-width="1920" data-height="1080">
<div id="s" class="stage clip" data-start="0" data-duration="3">
<div class="card" id="c0" style="left:300px;top:300px"></div><div class="card" id="c1" style="left:330px;top:402px"></div>
<div class="card" id="c2" style="left:360px;top:504px"></div><div class="ball" id="ball"></div>
</div>
</div>
<script>
// The composition at its own size, hidden, until its timeline plays: the code
// measures its layout as the renderer lays it out, not shrunk to the window.
(() => {
const root = document.getElementById('root');
if (!root) return;
Object.assign(root.style, {
width: (Number(root.dataset.width) || 1080) + 'px',
height: (Number(root.dataset.height) || 1920) + 'px',
visibility: 'hidden',
});
})();
</script>
<script>
const clamp = (v, a = 0, b = 1) => Math.min(b, Math.max(a, v));
const lerp = (a, b, u) => a + (b - a) * u;
// critically damped spring released at rest: 0 -> 1, omega in rad/s
const spring = (tau, w) => (tau <= 0 ? 0 : 1 - (1 + w * tau) * Math.exp(-w * tau));
const smooth = (u) => { u = clamp(u); return u * u * (3 - 2 * u); };
// a curve given at frames (60 fps) after an event: [frame, value] pairs
const keyed = (pairs, f) => { if (f <= pairs[0][0]) return pairs[0][1];
for (let i = 1; i < pairs.length; i++) if (f <= pairs[i][0]) { const [f0, v0] = pairs[i - 1], [f1, v1] = pairs[i]; return lerp(v0, v1, (f - f0) / (f1 - f0)); }
return pairs[pairs.length - 1][1]; };
const S = 1.8; document.getElementById("s").style.transform = `translate(120px, -340px) scale(${S})`;
const ball = document.getElementById("ball"), cards = [0, 1, 2].map((k) => document.getElementById("c" + k));
const R = 22, LIFT = 95; // ball radius and the arc's lift at mid-hop
const LAND = [0.5, 1.0, 1.5, 2.0]; // landing beats (s)
const SPOT = [[460, 300], [490, 402], [520, 504], [560, 640]]; // where each landing touches (top of a target)
const DIP = [[0, 0], [1, 2.2], [3, 4.8], [5, 5.5], [7, 3.0], [9, 0.9], [11, 0]];
function ballAt(t) {
if (t < LAND[0]) { const u = t / LAND[0]; return [SPOT[0][0], lerp(SPOT[0][1] - 260, SPOT[0][1], u * u) - R]; }
let k = 0; while (k < LAND.length - 2 && t > LAND[k + 1]) k++;
const u = clamp((t - LAND[k]) / (LAND[k + 1] - LAND[k]));
return [lerp(SPOT[k][0], SPOT[k + 1][0], u), lerp(SPOT[k][1], SPOT[k + 1][1], u) - R - 4 * LIFT * u * (1 - u)];
}
function draw(t) {
const [x, y] = ballAt(t);
let sx = 1, sy = 1;
const since = Math.min(...LAND.map((l) => (t >= l ? (t - l) * 60 : 99)));
if (since < 4) { const q = 1 - since / 4; sx = 1 + 0.3 * q; sy = 1 - 0.23 * q; } // squash for three frames
else { const [, y2] = ballAt(t + 1 / 60); if (y2 - y > 6) { sx = 0.95; sy = 1.05; } } // stretch in a fast fall
ball.style.transform = `translate(${x - R}px, ${y - R + R * (1 - sy)}px) scale(${sx}, ${sy})`;
cards.forEach((c, i) => { const f = (t - LAND[i]) * 60; c.style.transform = `translateY(${f > 0 && f < 11 ? keyed(DIP, f) : 0}px)`; });
}
const tl = gsap.timeline({ paused: true });
const clock = { t: 0 };
tl.to(clock, { t: 3, duration: 3, ease: "none", onUpdate: () => draw(clock.t) }, 0);
draw(0);
window.__timelines = window.__timelines || {};
window.__timelines["main"] = tl;
</script>
<script type="module">
// Once the code registers its timeline, which some do only after their fonts
// load, fit the composition to the window and play the timeline on a loop.
const root = document.getElementById('root');
const width = Number(root?.dataset.width) || 1080;
const height = Number(root?.dataset.height) || 1920;
const fit = () => {
if (!root) return;
const scale = Math.min(innerWidth / width, innerHeight / height);
Object.assign(root.style, {
width: width + 'px',
height: height + 'px',
transform: 'scale(' + scale + ')',
marginLeft: (innerWidth - width * scale) / 2 + 'px',
marginTop: (innerHeight - height * scale) / 2 + 'px',
});
};
const since = performance.now();
const play = () => {
const timeline = window.__timelines?.main;
if (!timeline && performance.now() - since < 5000) {
// Not a frame callback: those wait while the page is in the background.
setTimeout(play, 30);
return;
}
fit();
addEventListener('resize', fit);
if (root) root.style.visibility = '';
timeline?.repeat(-1).play(0);
};
play();
</script>
</body>
</html>
عند 0:01 من الفيديو0:01
بيانات
شريط تمرير يقوده مقبضه مع فقاعة قيمة تنقر
يُحسب التعبئة والعلامات والرقم كلها من x للمقبض: تنتهي التعبئة تحت المقبض، وتتحول كل علامة من العلامات الـ11 إلى لون التمييز بعد تجاوزها، وتكون القيمة (x - start) / (length / 100). تظهر الفقاعة من ذيلها بنابض مخمَّد حرجًا (omega 40) وتسير فوق المقبض؛ وعند تغيّر رقم ينزلق الجديد 6 وحدات من الأسفل بينما يغادر القديم إلى الأعلى خلال إطارين، فيُقرأ العدّ السريع كنقرة ناعمة لا كضبابية.
متى تُستخدمأي عرض للتقدم أو مستوى الصوت أو النتيجة يجب أن يبدو مرتبطًا فعليًا بما يقوده.
عرض الكود
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>شريط تمرير يقوده مقبضه مع فقاعة قيمة تنقر</title>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/gsap.min.js"></script>
<style>
html, body { margin: 0; height: 100%; overflow: hidden; background: #000; }
#root { position: relative; overflow: hidden; transform-origin: 0 0; }
</style>
<style>
@import url("https://fonts.googleapis.com/css2?family=Geist:wght@400;500;600;700&display=swap");
#root { position: relative; width: 100%; height: 100%; overflow: hidden; background: #0d0b1e; font-family: "Geist", sans-serif; color: #fff; }
.stage { position: absolute; left: 0; top: 0; width: 1px; height: 1px; transform-origin: 0 0; }
.stage > * { position: absolute; }
.track { left: 198px; top: -3.5px; width: 467px; height: 7px; border-radius: 3.5px; background: #353244; }
.fill { left: 198px; top: -3.5px; width: 0; height: 7px; border-radius: 3.5px; background: #fb2d89; }
#ticks { left: 0; top: 0; }
.tick { position: absolute; top: 33.3px; width: 3px; height: 10.2px; border-radius: 1.5px; background: #353244; }
.knob { left: 0; top: -22px; width: 44px; height: 44px; border-radius: 50%; background: #fff; }
.at { left: 0; top: -34px; width: 0; height: 0; transform-origin: 0 0; }
.bubble { position: absolute; left: 0; bottom: 5.7px; transform: translateX(-50%); height: 39.5px; padding: 0 12.4px; border-radius: 9px; background: #353244; display: flex; align-items: center; }
.bubble::after { content: ""; position: absolute; left: 50%; bottom: -5.6px; margin-left: -6px; border: 6px solid transparent; border-bottom: 0; border-top-color: #353244; }
.digit { position: relative; display: block; width: 14.3px; height: 26px; }
.digit span { position: absolute; left: 0; right: 0; text-align: center; font: 700 23px/26px "Geist", sans-serif; }
</style>
</head>
<body>
<div id="root" data-composition-id="main" data-start="0" data-duration="3" data-width="1920" data-height="1080">
<div id="s" class="stage clip" data-start="0" data-duration="3">
<div class="track"></div><div class="fill" id="fill"></div><div id="ticks"></div>
<div class="at" id="at"><div class="bubble" id="bubble"></div></div><div class="knob" id="knob"></div>
</div>
</div>
<script>
// The composition at its own size, hidden, until its timeline plays: the code
// measures its layout as the renderer lays it out, not shrunk to the window.
(() => {
const root = document.getElementById('root');
if (!root) return;
Object.assign(root.style, {
width: (Number(root.dataset.width) || 1080) + 'px',
height: (Number(root.dataset.height) || 1920) + 'px',
visibility: 'hidden',
});
})();
</script>
<script>
const clamp = (v, a = 0, b = 1) => Math.min(b, Math.max(a, v));
const lerp = (a, b, u) => a + (b - a) * u;
// critically damped spring released at rest: 0 -> 1, omega in rad/s
const spring = (tau, w) => (tau <= 0 ? 0 : 1 - (1 + w * tau) * Math.exp(-w * tau));
const smooth = (u) => { u = clamp(u); return u * u * (3 - 2 * u); };
// a curve given at frames (60 fps) after an event: [frame, value] pairs
const keyed = (pairs, f) => { if (f <= pairs[0][0]) return pairs[0][1];
for (let i = 1; i < pairs.length; i++) if (f <= pairs[i][0]) { const [f0, v0] = pairs[i - 1], [f1, v1] = pairs[i]; return lerp(v0, v1, (f - f0) / (f1 - f0)); }
return pairs[pairs.length - 1][1]; };
document.getElementById("s").style.transform = "translate(-310px, 560px) scale(2.83)";
const X0 = 213.2, X100 = 661.9, START = 0.4, END = 2.2; // value 0 and 100 in world units; the drag's span (s)
const knobX = (t) => lerp(X0, X100, gsap.parseEase("power3.out")(clamp((t - START) / (END - START))));
const ticks = Array.from({ length: 11 }, (_, k) => { const d = document.createElement("div"); d.className = "tick"; d.style.left = X0 + 44.87 * k - 1.5 + "px"; document.getElementById("ticks").appendChild(d); return d; });
const valueAt = (t) => Math.floor((knobX(t) - X0) / ((X100 - X0) / 100) + 1e-6);
const bubble = document.getElementById("bubble");
function digits(t) {
const v = valueAt(t), n = String(v).length, f = t * 60;
bubble.innerHTML = "";
for (let p = n - 1; p >= 0; p--) {
const div = 10 ** p, cur = Math.floor(v / div) % 10;
let back = 0; while (back < 90 && Math.floor(valueAt((f - back - 1) / 60) / div) === Math.floor(v / div)) back++;
const prev = Math.floor(valueAt((f - back - 1) / 60) / div) % 10, e = back >= 2 ? 1 : (back + 1) / 2; // 2-frame roll
const slot = document.createElement("span"); slot.className = "digit";
slot.innerHTML = `<span style="transform:translateY(${-6 * e}px);opacity:${e < 1 ? 1 - e : 0}">${prev}</span><span style="transform:translateY(${6 * (1 - e)}px);opacity:${e}">${cur}</span>`;
bubble.appendChild(slot);
}
}
function draw(t) {
const x = knobX(t);
document.getElementById("knob").style.transform = `translateX(${x - 22}px)`;
document.getElementById("fill").style.width = x - 198 + "px";
ticks.forEach((d, k) => (d.style.background = X0 + 44.87 * k <= x + 0.5 ? "#fb2d89" : "#353244"));
const s = spring(t - START, 40);
document.getElementById("at").style.transform = `translate(${x}px, -34px) scale(${s})`;
digits(t);
}
const tl = gsap.timeline({ paused: true });
const clock = { t: 0 };
tl.to(clock, { t: 3, duration: 3, ease: "none", onUpdate: () => draw(clock.t) }, 0);
draw(0);
window.__timelines = window.__timelines || {};
window.__timelines["main"] = tl;
</script>
<script type="module">
// Once the code registers its timeline, which some do only after their fonts
// load, fit the composition to the window and play the timeline on a loop.
const root = document.getElementById('root');
const width = Number(root?.dataset.width) || 1080;
const height = Number(root?.dataset.height) || 1920;
const fit = () => {
if (!root) return;
const scale = Math.min(innerWidth / width, innerHeight / height);
Object.assign(root.style, {
width: width + 'px',
height: height + 'px',
transform: 'scale(' + scale + ')',
marginLeft: (innerWidth - width * scale) / 2 + 'px',
marginTop: (innerHeight - height * scale) / 2 + 'px',
});
};
const since = performance.now();
const play = () => {
const timeline = window.__timelines?.main;
if (!timeline && performance.now() - since < 5000) {
// Not a frame callback: those wait while the page is in the background.
setTimeout(play, 30);
return;
}
fit();
addEventListener('resize', fit);
if (root) root.style.visibility = '';
timeline?.repeat(-1).play(0);
};
play();
</script>
</body>
</html>
عند 0:08 من الفيديو0:08
التخطيط
كومة بطاقات: ضربة، خروج متسارع، عودة بنابض متتابع
تنخفض كل بطاقة إشعار 5.5 وحدة عند الضربة وترتد خلال 11 إطارًا؛ وبعد 0.18 ث من الضربة تغادر بانزلاق متسارع (x = 125 u²، حيث u خلال 0.2 ث)، وتنخفض شفافيتها كـ 1 - u² ويزداد التمويه حتى 3 وحدات، فتتأخر قليلًا ثم تنطلق بعيدًا. لاحقًا تعود البطاقات من مسافة 145 وحدة إلى اليمين بنابض مخمَّد حرجًا (x = 145 (1 + 12.8 t) e^-12.8t) وتظهر خلال 0.12 ث، كل واحدة بعد 0.117 ث من التي فوقها.
متى تُستخدمالإشعارات أو رسائل toast أو صفوف القوائم التي تتفاعل مع اللمس وتُزاح بثقل وتعود كمجموعة.
عرض الكود
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>كومة بطاقات: ضربة، خروج متسارع، عودة بنابض متتابع</title>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/gsap.min.js"></script>
<style>
html, body { margin: 0; height: 100%; overflow: hidden; background: #000; }
#root { position: relative; overflow: hidden; transform-origin: 0 0; }
</style>
<style>
@import url("https://fonts.googleapis.com/css2?family=Geist:wght@400;500;600;700&display=swap");
#root { position: relative; width: 100%; height: 100%; overflow: hidden; background: #0d0b1e; font-family: "Geist", sans-serif; color: #fff; }
.stage { position: absolute; left: 0; top: 0; width: 1px; height: 1px; transform-origin: 0 0; }
.stage > * { position: absolute; }
.card { left: 0; width: 304px; height: 88px; border-radius: 14px; background: #261664; box-shadow: 0 9px 18px rgba(0, 0, 0, 0.38); }
.card::before { content: ""; position: absolute; left: 14.2px; top: 17.4px; width: 37.5px; height: 37.5px; border-radius: 8.4px; background: #fb2d89; }
.card b { position: absolute; left: 63.5px; top: 17.5px; font: 600 24px/24px "Geist", sans-serif; letter-spacing: -0.025em; }
.card i { position: absolute; left: 64.5px; top: 46px; font: 400 22.5px/24px "Geist", sans-serif; font-style: normal; color: #ccc6e3; }
</style>
</head>
<body>
<div id="root" data-composition-id="main" data-start="0" data-duration="4" data-width="1920" data-height="1080">
<div id="s" class="stage clip" data-start="0" data-duration="4">
<div class="card" id="c0" style="top:0px"><b>"App name"</b><i>"First message"</i></div>
<div class="card" id="c1" style="top:102.5px"><b>"Feature"</b><i>"Second message"</i></div>
<div class="card" id="c2" style="top:205px"><b>"App name"</b><i>"A question?"</i></div>
</div>
</div>
<script>
// The composition at its own size, hidden, until its timeline plays: the code
// measures its layout as the renderer lays it out, not shrunk to the window.
(() => {
const root = document.getElementById('root');
if (!root) return;
Object.assign(root.style, {
width: (Number(root.dataset.width) || 1080) + 'px',
height: (Number(root.dataset.height) || 1920) + 'px',
visibility: 'hidden',
});
})();
</script>
<script>
const clamp = (v, a = 0, b = 1) => Math.min(b, Math.max(a, v));
const lerp = (a, b, u) => a + (b - a) * u;
// critically damped spring released at rest: 0 -> 1, omega in rad/s
const spring = (tau, w) => (tau <= 0 ? 0 : 1 - (1 + w * tau) * Math.exp(-w * tau));
const smooth = (u) => { u = clamp(u); return u * u * (3 - 2 * u); };
// a curve given at frames (60 fps) after an event: [frame, value] pairs
const keyed = (pairs, f) => { if (f <= pairs[0][0]) return pairs[0][1];
for (let i = 1; i < pairs.length; i++) if (f <= pairs[i][0]) { const [f0, v0] = pairs[i - 1], [f1, v1] = pairs[i]; return lerp(v0, v1, (f - f0) / (f1 - f0)); }
return pairs[pairs.length - 1][1]; };
document.getElementById("s").style.transform = "translate(620px, 160px) scale(2.2)";
const cards = [0, 1, 2].map((k) => document.getElementById("c" + k));
const HIT = [0.4, 0.9, 1.4], AWAY = HIT.map((h) => h + 0.183), BACK = [2.6, 2.717, 2.834];
const DIP = [[0, 0], [1, 2.2], [3, 4.8], [5, 5.5], [7, 3.0], [9, 0.9], [11, 0]];
function draw(t) {
cards.forEach((c, k) => {
let x = 0, y = 0, op = 1, blur = 0;
const f = (t - HIT[k]) * 60; if (f > 0 && f < 11) y = keyed(DIP, f);
if (t >= AWAY[k] && t < BACK[k]) { const u = clamp((t - AWAY[k]) / 0.2); x = 125 * u * u; op = 1 - u * u; blur = 3 * u * u; }
else if (t >= BACK[k]) { const tau = t - BACK[k]; x = 145 * (1 + 12.8 * tau) * Math.exp(-12.8 * tau); op = smooth(tau / 0.12); }
c.style.transform = `translate(${x}px, ${y}px)`; c.style.opacity = op; c.style.filter = blur > 0.05 ? `blur(${blur}px)` : "none";
});
}
const tl = gsap.timeline({ paused: true });
const clock = { t: 0 };
tl.to(clock, { t: 4, duration: 4, ease: "none", onUpdate: () => draw(clock.t) }, 0);
draw(0);
window.__timelines = window.__timelines || {};
window.__timelines["main"] = tl;
</script>
<script type="module">
// Once the code registers its timeline, which some do only after their fonts
// load, fit the composition to the window and play the timeline on a loop.
const root = document.getElementById('root');
const width = Number(root?.dataset.width) || 1080;
const height = Number(root?.dataset.height) || 1920;
const fit = () => {
if (!root) return;
const scale = Math.min(innerWidth / width, innerHeight / height);
Object.assign(root.style, {
width: width + 'px',
height: height + 'px',
transform: 'scale(' + scale + ')',
marginLeft: (innerWidth - width * scale) / 2 + 'px',
marginTop: (innerHeight - height * scale) / 2 + 'px',
});
};
const since = performance.now();
const play = () => {
const timeline = window.__timelines?.main;
if (!timeline && performance.now() - since < 5000) {
// Not a frame callback: those wait while the page is in the background.
setTimeout(play, 30);
return;
}
fit();
addEventListener('resize', fit);
if (root) root.style.visibility = '';
timeline?.repeat(-1).play(0);
};
play();
</script>
</body>
</html>
عند 0:05 من الفيديو0:05
الطباعة
الكتابة بالاصطدامات: تنخفض المفاتيح عند هبوط الحروف
يُكتب الرد بكرة تضرب المفاتيح في إيقاعات ثابتة؛ ويعرض الحقل بالضبط ما ضُرب حتى تلك اللحظة. عند التركيز يظهر النص البديل خلال إطارين، ويظهر مؤشر بعرض 2 وحدة، ويقفز زر الإرسال من مركزه بنابض (omega 30). ينخفض كل مفتاح مضروب 4.5 وحدة ويسطع خلال 9 إطارات، بينما يظهر حرفه خلال إطارين ويتحرك المؤشر بعده.
متى تُستخدمعروض الدردشة والبحث التي يجب أن يبدو فيها الإدخال ناتجًا عن شيء ما، لا مكتوبًا بيد شبح.
عرض الكود
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>الكتابة بالاصطدامات: تنخفض المفاتيح عند هبوط الحروف</title>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/gsap.min.js"></script>
<style>
html, body { margin: 0; height: 100%; overflow: hidden; background: #000; }
#root { position: relative; overflow: hidden; transform-origin: 0 0; }
</style>
<style>
@import url("https://fonts.googleapis.com/css2?family=Geist:wght@400;500;600;700&display=swap");
#root { position: relative; width: 100%; height: 100%; overflow: hidden; background: #0d0b1e; font-family: "Geist", sans-serif; color: #fff; }
.stage { position: absolute; left: 0; top: 0; width: 1px; height: 1px; transform-origin: 0 0; }
.stage > * { position: absolute; }
.pill { left: 333.8px; top: 402.4px; width: 171.9px; height: 51.8px; border-radius: 25.9px; background: #160b44; border: 1.5px solid #353244; }
.ph, .typed { position: absolute; left: 20px; top: 12.7px; font: 400 24px/24px "Geist", sans-serif; white-space: nowrap; }
.ph { color: #6b6385; } .typed { display: flex; align-items: center; }
.caret { display: inline-block; width: 2.2px; height: 28.5px; margin-left: 1.5px; background: #fb2d89; }
.send { position: absolute; left: 126.1px; top: 7.95px; width: 34.5px; height: 34.5px; border-radius: 50%; background: #fb2d89; transform: scale(0); }
.key { position: absolute; width: 58.2px; height: 54.2px; border-radius: 6.5px; background: rgb(48,33,108); display: flex; align-items: center; justify-content: center; font: 500 24px "Geist", sans-serif; }
.ball { left: 0; top: 0; width: 44px; height: 44px; border-radius: 50%; background: #fff; }
</style>
</head>
<body>
<div id="root" data-composition-id="main" data-start="0" data-duration="4" data-width="1920" data-height="1080">
<div id="s" class="stage clip" data-start="0" data-duration="4">
<div class="pill"><div class="ph" id="ph">"Reply"</div><div class="typed" id="typed"></div><div class="send" id="send"></div></div>
<div id="keys"></div><div class="ball" id="ball"></div>
</div>
</div>
<script>
// The composition at its own size, hidden, until its timeline plays: the code
// measures its layout as the renderer lays it out, not shrunk to the window.
(() => {
const root = document.getElementById('root');
if (!root) return;
Object.assign(root.style, {
width: (Number(root.dataset.width) || 1080) + 'px',
height: (Number(root.dataset.height) || 1920) + 'px',
visibility: 'hidden',
});
})();
</script>
<script>
const clamp = (v, a = 0, b = 1) => Math.min(b, Math.max(a, v));
const lerp = (a, b, u) => a + (b - a) * u;
// critically damped spring released at rest: 0 -> 1, omega in rad/s
const spring = (tau, w) => (tau <= 0 ? 0 : 1 - (1 + w * tau) * Math.exp(-w * tau));
const smooth = (u) => { u = clamp(u); return u * u * (3 - 2 * u); };
// a curve given at frames (60 fps) after an event: [frame, value] pairs
const keyed = (pairs, f) => { if (f <= pairs[0][0]) return pairs[0][1];
for (let i = 1; i < pairs.length; i++) if (f <= pairs[i][0]) { const [f0, v0] = pairs[i - 1], [f1, v1] = pairs[i]; return lerp(v0, v1, (f - f0) / (f1 - f0)); }
return pairs[pairs.length - 1][1]; };
document.getElementById("s").style.transform = "translate(-640px, -560px) scale(2.49)";
const ROWS = [["QWERTYUIOP", 490.1, 516], ["ASDFGHJKL", 508.45, 581.2]], PITCH = 65.4;
const keys = {};
for (const [s, x0, y0] of ROWS) [...s].forEach((ch, i) => { const d = document.createElement("div"); d.className = "key"; d.textContent = ch;
d.style.left = x0 + PITCH * i + "px"; d.style.top = y0 + "px"; document.getElementById("keys").appendChild(d); keys[ch] = d; });
const FOCUS = 0.98, HITS = [1.0, 1.5, 2.0, 2.5, 3.0], TEXT = ["t", "r", "y", " i", "t"]; // one key per beat
const KEYS = TEXT.map((c) => c.trim().toUpperCase());
const PRESS = [[0, 0.7], [1, 2.4], [2, 3.9], [3, 4.5], [4, 4.2], [5, 3.6], [6, 2.4], [7, 1.1], [8, 0.5], [9, 0]];
const keyX = (ch) => parseFloat(keys[ch].style.left) + 29.1;
function ballAt(t) { // hops on the top row: x linear, a 78-unit lift at mid-hop
if (t < HITS[0]) return [keyX(KEYS[0]), 494 - 78 * (1 - t / HITS[0]) ** 2];
let k = 0; while (k < HITS.length - 2 && t > HITS[k + 1]) k++;
const u = clamp((t - HITS[k]) / (HITS[k + 1] - HITS[k]));
return [lerp(keyX(KEYS[k]), keyX(KEYS[k + 1]), u), 494 - 4 * 78 * u * (1 - u)];
}
function draw(t) {
document.getElementById("ph").style.opacity = 1 - clamp((t - FOCUS) / 0.033);
const typed = TEXT.map((c, i) => (t >= HITS[i] ? `<span style="opacity:${clamp((t - HITS[i]) / 0.033 + 0.15)}">${c.replace(" ", " ")}</span>` : "")).join("");
document.getElementById("typed").innerHTML = t >= FOCUS ? typed + '<i class="caret"></i>' : "";
document.getElementById("send").style.transform = `scale(${spring(t - FOCUS, 30)})`;
for (const d of Object.values(keys)) { d.style.transform = ""; d.style.background = "rgb(48,33,108)"; }
KEYS.forEach((ch, i) => { const f = (t - HITS[i]) * 60; if (f < 0 || f > 10) return;
const g = Math.max(0, 1 - Math.abs(f - 5) / 5) * 10; keys[ch].style.transform = `translateY(${keyed(PRESS, f)}px)`;
keys[ch].style.background = `rgb(${48 + g},${33 + g},${108 + g})`; });
const [x, y] = ballAt(t); document.getElementById("ball").style.transform = `translate(${x - 22}px, ${y - 22}px)`;
}
const tl = gsap.timeline({ paused: true });
const clock = { t: 0 };
tl.to(clock, { t: 4, duration: 4, ease: "none", onUpdate: () => draw(clock.t) }, 0);
draw(0);
window.__timelines = window.__timelines || {};
window.__timelines["main"] = tl;
</script>
<script type="module">
// Once the code registers its timeline, which some do only after their fonts
// load, fit the composition to the window and play the timeline on a loop.
const root = document.getElementById('root');
const width = Number(root?.dataset.width) || 1080;
const height = Number(root?.dataset.height) || 1920;
const fit = () => {
if (!root) return;
const scale = Math.min(innerWidth / width, innerHeight / height);
Object.assign(root.style, {
width: width + 'px',
height: height + 'px',
transform: 'scale(' + scale + ')',
marginLeft: (innerWidth - width * scale) / 2 + 'px',
marginTop: (innerHeight - height * scale) / 2 + 'px',
});
};
const since = performance.now();
const play = () => {
const timeline = window.__timelines?.main;
if (!timeline && performance.now() - since < 5000) {
// Not a frame callback: those wait while the page is in the background.
setTimeout(play, 30);
return;
}
fit();
addEventListener('resize', fit);
if (root) root.style.visibility = '';
timeline?.repeat(-1).play(0);
};
play();
</script>
</body>
</html>
عند 0:08 من الفيديو0:08
الكاميرا
تمويه حركة دون الإطار من نسخ طبقات مكدسة
يُبنى المشهد كله 4 مرات كطبقات، تُرسم كل منها في لحظة موزعة على نصف إطار حول زمن الإطار (-0.25 و-0.08 و+0.08 و+0.25 إطار) وتُكدَّس بشفافيات 1 و1/2 و1/3 و1/4، وهذا يحسب متوسطها بدقة: تتلطخ حركات الكاميرا السريعة كما في غالق حقيقي بينما يبقى النص حادًا في السكون. تظهر النسخ فقط عندما يتحرك شيء على الشاشة أكثر من نحو 1.2 px أثناء الغالق، وتوسَم كنسخ لتدقيق التخطيط.
متى تُستخدمالتحريكات والتكبيرات والتحليقات السريعة في أفلام الواجهات التي يجب أن تُقرأ كحركة كاميرا لا كتقطع.
عرض الكود
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>تمويه حركة دون الإطار من نسخ طبقات مكدسة</title>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/gsap.min.js"></script>
<style>
html, body { margin: 0; height: 100%; overflow: hidden; background: #000; }
#root { position: relative; overflow: hidden; transform-origin: 0 0; }
</style>
<style>
@import url("https://fonts.googleapis.com/css2?family=Geist:wght@400;500;600;700&display=swap");
#root { position: relative; width: 100%; height: 100%; overflow: hidden; background: #0d0b1e; font-family: "Geist", sans-serif; color: #fff; }
.stage { position: absolute; left: 0; top: 0; width: 1px; height: 1px; transform-origin: 0 0; }
.stage > * { position: absolute; }
#stage, .layer { position: absolute; left: 0; top: 0; width: 1920px; height: 1080px; background: #0d0b1e; }
.world { position: absolute; left: 0; top: 0; width: 1px; height: 1px; transform-origin: 0 0; }
.card { position: absolute; width: 304px; height: 88px; padding-left: 24px; border-radius: 14px; background: #261664; font: 600 24px/88px "Geist", sans-serif; }
</style>
</head>
<body>
<div id="root" data-composition-id="main" data-start="0" data-duration="4" data-width="1920" data-height="1080">
<div id="stage" class="clip" data-start="0" data-duration="4"></div>
</div>
<script>
// The composition at its own size, hidden, until its timeline plays: the code
// measures its layout as the renderer lays it out, not shrunk to the window.
(() => {
const root = document.getElementById('root');
if (!root) return;
Object.assign(root.style, {
width: (Number(root.dataset.width) || 1080) + 'px',
height: (Number(root.dataset.height) || 1920) + 'px',
visibility: 'hidden',
});
})();
</script>
<script>
const LAYERS = 4, SHUTTER = 0.5; // samples per frame and their spread, in frames
const ease = gsap.parseEase("power3.inOut");
const camAt = (t) => { const u = ease(Math.min(1, Math.max(0, (t - 0.8) / 1.6))); // a fast pull-back and pan
return { x: 700 - 450 * u, y: 330 - 150 * u, z: Math.exp(Math.log(2.6) + (Math.log(1.4) - Math.log(2.6)) * u) }; };
const layers = Array.from({ length: LAYERS }, (_, j) => {
const el = document.createElement("div"); el.className = "layer"; el.style.opacity = 1 / (j + 1);
if (j > 0) el.setAttribute("data-layout-ignore", "");
el.innerHTML = '<div class="world">' + ['"First card"', '"Second card"', '"Third card"'].map((s, k) => `<div class="card" style="left:${534 + 13 * k}px;top:${208 + 102.5 * k}px">${s}</div>`).join("") + "</div>";
document.getElementById("stage").appendChild(el); return el;
});
function drawLayer(el, t) { const c = camAt(t); el.firstChild.style.transform = `translate(${960 - c.x * c.z}px, ${540 - c.y * c.z}px) scale(${c.z})`; }
function render(t) {
const h = SHUTTER / 2 / 60, a = camAt(t - h), b = camAt(t + h);
const moving = Math.hypot((a.x - b.x) * b.z, (a.y - b.y) * b.z) + Math.abs(a.z - b.z) * 900 > 1.2;
layers.forEach((el, j) => { el.style.display = j === 0 || moving ? "block" : "none";
drawLayer(el, moving ? t + (j / (LAYERS - 1) - 0.5) * SHUTTER / 60 : t); });
}
const tl = gsap.timeline({ paused: true });
const clock = { t: 0 };
tl.to(clock, { t: 4, duration: 4, ease: "none", onUpdate: () => render(clock.t) }, 0);
render(0);
window.__timelines = window.__timelines || {};
window.__timelines["main"] = tl;
</script>
<script type="module">
// Once the code registers its timeline, which some do only after their fonts
// load, fit the composition to the window and play the timeline on a loop.
const root = document.getElementById('root');
const width = Number(root?.dataset.width) || 1080;
const height = Number(root?.dataset.height) || 1920;
const fit = () => {
if (!root) return;
const scale = Math.min(innerWidth / width, innerHeight / height);
Object.assign(root.style, {
width: width + 'px',
height: height + 'px',
transform: 'scale(' + scale + ')',
marginLeft: (innerWidth - width * scale) / 2 + 'px',
marginTop: (innerHeight - height * scale) / 2 + 'px',
});
};
const since = performance.now();
const play = () => {
const timeline = window.__timelines?.main;
if (!timeline && performance.now() - since < 5000) {
// Not a frame callback: those wait while the page is in the background.
setTimeout(play, 30);
return;
}
fit();
addEventListener('resize', fit);
if (root) root.style.visibility = '';
timeline?.repeat(-1).play(0);
};
play();
</script>
</body>
</html>
عند 0:00 من الفيديو0:00
أشكال
مفتاح بمقبض يتمدد ويغادر ككرة
يصل مؤشر إلى المفتاح بنابض (omega 24) وينقر؛ يتمدد المقبض البالغ 44 وحدة إلى نحو 53 x 36 أثناء انزلاقه إلى جهة التشغيل خلال 0.15 ث، ويتحول المسار من الرمادي إلى لون التمييز بنابض مخمَّد حرجًا (omega 25). ثم يرتفع المقبض في قوس ويواصل كرة حرة، ويبقى المفتاح مشغَّلًا وفارغًا؛ ولاحقًا تسقط الكرة عائدة كمقبض ويعود المسار رماديًا خلال 0.135 ث.
متى تُستخدمنقرة افتتاحية تسلّم القصة إلى جسم متحرك، أو أي مفتاح يجب أن يبدو ليّنًا وماديًا.
عرض الكود
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>مفتاح بمقبض يتمدد ويغادر ككرة</title>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/gsap.min.js"></script>
<style>
html, body { margin: 0; height: 100%; overflow: hidden; background: #000; }
#root { position: relative; overflow: hidden; transform-origin: 0 0; }
</style>
<style>
@import url("https://fonts.googleapis.com/css2?family=Geist:wght@400;500;600;700&display=swap");
#root { position: relative; width: 100%; height: 100%; overflow: hidden; background: #0d0b1e; font-family: "Geist", sans-serif; color: #fff; }
.stage { position: absolute; left: 0; top: 0; width: 1px; height: 1px; transform-origin: 0 0; }
.stage > * { position: absolute; }
.track { left: -27px; top: -25.9px; width: 91.4px; height: 51.8px; border-radius: 25.9px; background: #353244; }
.knob { left: 0; top: 0; width: 44px; height: 44px; border-radius: 50%; background: #fff; }
.cursor { left: 0; top: 0; width: 38px; height: 54px; overflow: visible; }
</style>
</head>
<body>
<div id="root" data-composition-id="main" data-start="0" data-duration="4" data-width="1920" data-height="1080">
<div id="s" class="stage clip" data-start="0" data-duration="4">
<div class="track" id="track"></div><div class="knob" id="knob"></div>
<svg class="cursor" id="cursor" viewBox="-1.5 -1.5 38 54"><path d="M1.2 1.9V42.6L11.9 32.8L17.6 47.2L22.1 45.3L18.2 31.4H32.2Z" fill="#0d0b1e" stroke="#fff" stroke-width="2.4" stroke-linejoin="round"/></svg>
</div>
</div>
<script>
// The composition at its own size, hidden, until its timeline plays: the code
// measures its layout as the renderer lays it out, not shrunk to the window.
(() => {
const root = document.getElementById('root');
if (!root) return;
Object.assign(root.style, {
width: (Number(root.dataset.width) || 1080) + 'px',
height: (Number(root.dataset.height) || 1920) + 'px',
visibility: 'hidden',
});
})();
</script>
<script>
const clamp = (v, a = 0, b = 1) => Math.min(b, Math.max(a, v));
const lerp = (a, b, u) => a + (b - a) * u;
// critically damped spring released at rest: 0 -> 1, omega in rad/s
const spring = (tau, w) => (tau <= 0 ? 0 : 1 - (1 + w * tau) * Math.exp(-w * tau));
const smooth = (u) => { u = clamp(u); return u * u * (3 - 2 * u); };
// a curve given at frames (60 fps) after an event: [frame, value] pairs
const keyed = (pairs, f) => { if (f <= pairs[0][0]) return pairs[0][1];
for (let i = 1; i < pairs.length; i++) if (f <= pairs[i][0]) { const [f0, v0] = pairs[i - 1], [f1, v1] = pairs[i]; return lerp(v0, v1, (f - f0) / (f1 - f0)); }
return pairs[pairs.length - 1][1]; };
document.getElementById("s").style.transform = "translate(800px, 540px) scale(3.95)";
const CLICK = 1.0, BACK = 3.0, OFF = [53, 50, 68], ON = [251, 45, 137];
// the knob while pressed: [frame after the click, x, width, height], measured from a real switch move
const PRESSED = [[0, 0, 44, 44], [2, 0.8, 45.8, 41.8], [4, 6.2, 48.1, 40], [6, 15.2, 50.1, 38.5], [8, 27.9, 51.9, 36.5], [9, 35.7, 52.9, 35.9]];
function knobAt(t) {
const f = (t - CLICK) * 60;
if (f < 0) return [0, 0, 44, 44];
if (f <= 9) { const i = PRESSED.findIndex((p) => p[0] >= f), [f0, x0, w0, h0] = PRESSED[Math.max(0, i - 1)], [f1, x1, w1, h1] = PRESSED[i];
const u = f1 === f0 ? 1 : (f - f0) / (f1 - f0); return [lerp(x0, x1, u), 0, lerp(w0, w1, u), lerp(h0, h1, u)]; }
if (t < BACK) { const u = clamp((t - CLICK - 0.15) / (BACK - CLICK - 0.15)); // out on an arc, round and back in as the knob
return [lerp(35.7, 0, u) + 420 * Math.sin(Math.PI * u), -300 * Math.sin(Math.PI * u), 44, 44]; }
return [0, 0, 44, 44];
}
function draw(t) {
const [x, y, w, h] = knobAt(t);
const k = document.getElementById("knob"); k.style.width = w + "px"; k.style.height = h + "px";
k.style.transform = `translate(${x - w / 2}px, ${y - h / 2}px)`;
const on = t < CLICK ? 0 : t < BACK ? spring(t - CLICK, 25) : 1 - smooth((t - BACK) / 0.135);
document.getElementById("track").style.background = `rgb(${OFF.map((v, i) => Math.round(lerp(v, ON[i], on))).join(",")})`;
const u = t < CLICK ? spring(t - 0.3, 24) : 1 - spring(t - CLICK - 0.4, 24); // the cursor comes in, clicks, leaves
document.getElementById("cursor").style.transform = `translate(${lerp(110, 24.3, u)}px, ${lerp(100, 4.4, u)}px)`;
}
const tl = gsap.timeline({ paused: true });
const clock = { t: 0 };
tl.to(clock, { t: 4, duration: 4, ease: "none", onUpdate: () => draw(clock.t) }, 0);
draw(0);
window.__timelines = window.__timelines || {};
window.__timelines["main"] = tl;
</script>
<script type="module">
// Once the code registers its timeline, which some do only after their fonts
// load, fit the composition to the window and play the timeline on a loop.
const root = document.getElementById('root');
const width = Number(root?.dataset.width) || 1080;
const height = Number(root?.dataset.height) || 1920;
const fit = () => {
if (!root) return;
const scale = Math.min(innerWidth / width, innerHeight / height);
Object.assign(root.style, {
width: width + 'px',
height: height + 'px',
transform: 'scale(' + scale + ')',
marginLeft: (innerWidth - width * scale) / 2 + 'px',
marginTop: (innerHeight - height * scale) / 2 + 'px',
});
};
const since = performance.now();
const play = () => {
const timeline = window.__timelines?.main;
if (!timeline && performance.now() - since < 5000) {
// Not a frame callback: those wait while the page is in the background.
setTimeout(play, 30);
return;
}
fit();
addEventListener('resize', fit);
if (root) root.style.visibility = '';
timeline?.repeat(-1).play(0);
};
play();
</script>
</body>
</html>
تحفظ ملفات تعريف الارتباط الضرورية إعداداتك على الموقع. وبإذنك، يساعدنا Google Analytics على فهم طريقة استخدام Motion Fab. يمكنك تغيير اختيارك من تذييل الصفحة.
خياراتك المتعلقة بالخصوصية بموجب قوانين الخصوصية المعمول بها في الولايات الأمريكية. سياسة الخصوصية