Core Features
Learn about YakaJS's 15+ built-in animations and effects
YakaJS includes 15+ smooth, performant animations out of the box. No additional libraries needed!
// Simple fade in_('#element').fadeIn();// Chain multiple animations_('#element') .fadeIn(500) .bounce() .swing();// With callback_('#element').fadeOut(300, () => { console.log('Animation complete!');});Fade element in from invisible to visible.
_('#element').fadeIn(); // Default 400ms_('#element').fadeIn(1000); // Custom duration_('#element').fadeIn(500, () => { // With callback console.log('Fade in complete!');});Fade element out from visible to invisible.
_('#element').fadeOut();_('#element').fadeOut(800);_('#element').fadeOut(300, () => { _('#element').remove(); // Remove after fading out});Toggle between fadeIn and fadeOut.
_('#element').fadeToggle(); // Toggle with default duration_('#element').fadeToggle(600); // Custom durationSlide element down to reveal it.
_('#menu').slideDown();_('#menu').slideDown(500);Slide element up to hide it.
_('#menu').slideUp();_('#menu').slideUp(300);Toggle between slideDown and slideUp.
_('#panel').slideToggle();_('#panel').slideToggle(400);Slide element to the left.
_('#sidebar').slideLeft(500);Slide element to the right.
_('#sidebar').slideRight(500);Bouncing animation effect.
_('#button').bounce();_('#button').bounce(800);// Bounce on click_('#button').on('click', function() { _(this).bounce();});Shake animation (great for errors).
_('#loginForm').shake(); // Shake to indicate error// Example: shake on invalid input_('#submitBtn').on('click', () => { if (!isValid()) { _('#form').shake(); }});Swinging animation effect.
_('#notification').swing();Pulsing scale animation.
_('#heart').pulse(); // Pulse effect_('#heart').pulse(1000); // Slower pulse// Continuous pulsesetInterval(() => { _('#indicator').pulse();}, 2000);Rubber band stretching effect.
_('#elastic').rubberBand();Wobbling animation.
_('#jellyElement').wobble();Flashing opacity animation.
_('#alert').flash(); // Flash effect_('#notification').flash(600);Jello-like wobble effect.
_('#funButton').jello();Heartbeat scale animation.
_('#liveIndicator').heartBeat();// Continuous heartbeatsetInterval(() => { _('#status').heartBeat();}, 1500);3D flip animation.
_('#card').flip3D(); // Default horizontal flip_('#card').flip3D('horizontal');_('#card').flip3D('vertical');_('#card').flip3D('diagonal');Rotate in with 3D effect.
_('#modal').rotateIn();_('#modal').rotateIn(800);Rotate out with 3D effect.
_('#modal').rotateOut();_('#modal').rotateOut(600);One of the most powerful features is the ability to chain multiple animations:
// Simple chain_('#element') .fadeIn(500) .bounce() .swing();// Complex sequence_('#notification') .slideDown(300) .pulse() .delay(2000) // Wait 2 seconds .shake() .delay(1000) .slideUp(300);// With callback_('#modal') .fadeIn(400) .bounce() .delay(3000) .fadeOut(400, () => { console.log('Modal closed'); });// Show loading with pulse_('#loader') .show() .pulse();// Hide when donefetch('/api/data') .then(data => { _('#loader').fadeOut(300); _('#content').fadeIn(500); });function showSuccess(message) { _('#success') .text(message) .fadeIn(300) .bounce() .delay(3000) .fadeOut(500);}// UsageshowSuccess('Profile saved successfully!');function showError(field) { _(field) .addClass('error') .shake() .delay(500) .removeClass('error');}// Usageif (!emailValid) { showError('#emailInput');}// Show modalfunction openModal(selector) { _(selector) .css('display', 'flex') .fadeIn(300) .find('.modal-content') .rotateIn(400);}// Hide modalfunction closeModal(selector) { _(selector) .find('.modal-content') .rotateOut(300) .parent() .delay(300) .fadeOut(200);}// Usage_('#openBtn').on('click', () => openModal('#myModal'));_('#closeBtn').on('click', () => closeModal('#myModal'));// Add item with animationfunction addListItem(text) { const item = _('<li>').text(text); _('#list') .append(item); item.css('opacity', 0) .slideDown(300) .fadeIn(300) .bounce();}// Remove item with animation_('#list').on('click', '.delete', function() { _(this).parent() .shake() .delay(300) .slideUp(300, function() { _(this).remove(); });});function navigateWithAnimation(url) { _('#content') .fadeOut(300) .slideUp(300, () => { // Load new content loadPage(url); // Animate new content in _('#content') .slideDown(300) .fadeIn(400); });}_('[data-tooltip]').on('mouseenter', function() { const text = _(this).attr('data-tooltip'); const tooltip = _('<div class="tooltip">') .text(text) .css({ position: 'absolute', top: _(this).offset().top - 40, left: _(this).offset().left }); _('body').append(tooltip); tooltip.fadeIn(200).pulse();});_('[data-tooltip]').on('mouseleave', function() { _('.tooltip').fadeOut(200, function() { _(this).remove(); });});YakaJS animations use CSS transforms which are hardware-accelerated for better performance:
// These are performant (hardware accelerated)_('#element').fadeIn(); // Uses opacity_('#element').bounce(); // Uses transform_('#element').slideDown(); // Uses transformAnimate multiple elements efficiently:
// Good: Batch animation_('.cards').each((i, card) => { setTimeout(() => { _(card).fadeIn().bounce(); }, i * 100); // Stagger by 100ms});// Also good: Animate all at once_('.notifications').fadeIn(300).bounce();// Good: Use YakaJS batch operations_('.items').css('display', 'none'); // Batched_('.items').fadeIn();// Avoid: Reading then writing in loop// This causes layout thrashing_('.items').each((i, item) => { const height = item.offsetHeight; // Read (bad in loop) item.style.height = height + 'px'; // Write (bad in loop)});All animations accept custom durations in milliseconds:
_('#element').fadeIn(100); // Fast (100ms)_('#element').fadeIn(400); // Default (400ms)_('#element').fadeIn(1000); // Slow (1000ms)_('#element').fadeIn(2500); // Very slow (2.5s)Listen for animation complete events:
_('#element').fadeIn(500, () => { console.log('Fade in complete!'); // Do something after animation});// Chain with callback_('#modal') .fadeIn(300) .bounce() .delay(2000) .fadeOut(300, () => { _('#modal').remove(); });YakaJS animations work in all modern browsers:
Animations work great with voice commands:
_.voice.listen({ 'bounce': () => _('#element').bounce(), 'shake': () => _('#element').shake(), 'spin': () => _('#element').flip3D(), 'fade out': () => _('#element').fadeOut(), 'fade in': () => _('#element').fadeIn(), 'show': () => _('#element').slideDown().fadeIn(), 'hide': () => _('#element').fadeOut().slideUp()});Try saying "bounce" or "shake" to see animations triggered by voice! 🎤
Animations make your web applications feel alive and professional. Experiment with different combinations to find what works best for your UI!
For the complete list of methods, see the API Reference.