| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798 |
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <meta charset="UTF-8">
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
- <title>CSS Properties - Animal.js</title>
- <link rel="stylesheet" href="../demo.css">
- <style>
- .prop-box {
- width: 50px;
- height: 50px;
- background-color: var(--highlight-color);
- border-radius: 4px;
- margin-bottom: 20px;
- }
- .demo-visual { padding: 40px; display: flex; flex-direction: column; align-items: center; }
- </style>
- </head>
- <body>
- <div class="container">
- <!-- Breadcrumb / Header -->
- <div style="font-size: 10px; font-weight: bold; letter-spacing: 1px; color: #ff4b4b; margin-bottom: 20px;">ANIMATION > ANIMATABLE PROPERTIES</div>
-
- <h1>CSS Properties</h1>
- <p class="description">Animate any CSS property.</p>
- <div class="box-container">
- <div class="box-header">
- <div class="box-title">CSS Property example</div>
- <div class="tabs">
- <div class="tab active" onclick="switchTab('js')">JavaScript</div>
- <div class="tab" onclick="switchTab('html')">HTML</div>
- </div>
- </div>
- <div id="js-code" class="code-view active">
- <span class="fun">animate</span><span class="punc">(</span><span class="str">'.prop-box'</span><span class="punc">,</span> <span class="punc">{</span>
- width<span class="punc">:</span> <span class="str">'100px'</span><span class="punc">,</span>
- backgroundColor<span class="punc">:</span> <span class="str">'#FFF'</span><span class="punc">,</span>
- borderRadius<span class="punc">:</span> <span class="str">'50%'</span>
- <span class="punc">}</span><span class="punc">)</span><span class="punc">;</span>
- </div>
- <div id="html-code" class="html-view">
- <span class="tag"><div</span> <span class="attr">class</span>=<span class="val">"prop-box"</span><span class="tag">></div></span>
- </div>
- <div class="demo-visual">
- <div class="prop-box"></div>
- </div>
-
- <div class="action-bar">
- <button class="play-btn" onclick="runDemo()">REPLAY</button>
- </div>
- </div>
- </div>
- <script src="../../animal.js"></script>
- <script>
- function switchTab(tab) {
- document.querySelectorAll('.tab').forEach(t => t.classList.remove('active'));
- document.querySelectorAll('.code-view, .html-view').forEach(v => v.classList.remove('active'));
- if (tab === 'js') {
- document.getElementById('js-code').classList.add('active');
- } else {
- document.getElementById('html-code').classList.add('active');
- }
- }
- function runDemo() {
- // Reset
- const el = document.querySelector('.prop-box');
- el.style.width = '50px';
- el.style.backgroundColor = ''; // Reset to CSS var
- el.style.borderRadius = '4px';
-
- // Note: animal.js supports basic transforms/opacity via WAAPI.
- // For other CSS props like width/color, it falls back to JS interpolation if implemented,
- // or WAAPI if supported by browser.
- // animal.js "lite" implementation mostly focuses on transforms/opacity in WAAPI path.
- // The JS fallback in animal.js handles other props!
-
- animal.animate('.prop-box', {
- width: '100px',
- backgroundColor: '#FFF', // Color interpolation might need specific handling or rely on browser WAAPI if keys match
- borderRadius: '50%',
- duration: 1000,
- easing: 'ease-in-out'
- });
- }
-
- setTimeout(runDemo, 500);
- </script>
- </body>
- </html>
|