1. Home
  2. /
  3. Animejs
  4. /
  5. Rotate and Scale

Rotate and Scale - Animejs Typing CST Test

Loading…

Rotate and Scale — Animejs Code

Rotates and scales a div simultaneously.

# animejs/demo/rotate_scale.html
<html>
	<head>
		<script src="https://cdn.jsdelivr.net/npm/animejs@3.2.1/lib/anime.min.js"></script>
	</head>
	<body>
		<div id="box" style="width:100px;height:100px;background:purple;"></div>
		<script>
		anime({
		targets: '#box',
		rotate: 360,
		scale: 1.5,
		duration: 2000,
		repeat: Infinity,
		yoyo: true
		});
		</script>
	</body>
</html>

Animejs Language Guide

Anime.js is a lightweight JavaScript animation library that enables developers to create smooth, complex, and performant animations on the web. It works with CSS properties, SVG, DOM attributes, and JavaScript objects.

Primary Use Cases

  • ▸Animating CSS properties like opacity, transform, and color
  • ▸SVG morphing and path animations
  • ▸UI micro-interactions (buttons, menus, modals)
  • ▸Data visualizations and chart animations
  • ▸Sequenced animations via timelines

Notable Features

  • ▸CSS, SVG, DOM, and JS object animation support
  • ▸Powerful easing functions and custom easing
  • ▸Timeline control for synchronized sequences
  • ▸Animation looping and direction control
  • ▸Callback events for animation lifecycle (begin, update, complete)

Origin & Creator

Anime.js was created by Julian Garnier in 2015 as a lightweight, versatile animation library for the web.

Industrial Note

Anime.js is widely used for interactive web applications, marketing pages, dashboards, data visualizations, micro-interactions, and SVG-based animations.

Quick Explain

  • ▸Anime.js allows precise control over animations with timelines, easing functions, and callbacks.
  • ▸It supports animating numeric CSS properties, SVG elements, DOM attributes, and JavaScript objects.
  • ▸Developers can chain and synchronize animations with timelines for complex sequences.
  • ▸It is framework-agnostic and can be used with vanilla JS, React, Vue, or Angular.
  • ▸Anime.js handles browser inconsistencies and ensures smooth performance via requestAnimationFrame.

Core Features

  • ▸animate() - main function for creating animations
  • ▸timeline() - sequences and sync multiple animations
  • ▸Easing functions (linear, spring, elastic, etc.)
  • ▸Keyframes support for multi-step animations
  • ▸Play, pause, reverse, restart controls

Learning Path

  • ▸Learn basic CSS/JS animation principles
  • ▸Understand anime() and its options
  • ▸Practice animating DOM elements and SVGs
  • ▸Learn timelines and easing functions
  • ▸Build complex interactive sequences for web UI

Practical Examples

  • ▸Fading in/out elements with opacity
  • ▸Sliding menus and panels
  • ▸Animating charts and graphs
  • ▸SVG icon morphing animations
  • ▸Scroll-triggered interactive animations

Comparisons

  • ▸Anime.js vs GSAP: Anime.js lightweight, GSAP more features
  • ▸Anime.js vs Velocity.js: Anime.js modern, Velocity older
  • ▸Anime.js vs CSS animations: Anime.js more control and sequencing
  • ▸Anime.js vs Framer Motion: Anime.js JS-based, Framer Motion React-specific
  • ▸Anime.js vs Three.js animation: Anime.js for DOM/SVG, Three.js for 3D objects

Strengths

  • ▸Lightweight and performant
  • ▸Simple API with high flexibility
  • ▸Cross-browser support
  • ▸Works seamlessly with modern frameworks
  • ▸Ideal for interactive and complex animation sequences

Limitations

  • ▸Not a full game engine animation system
  • ▸Requires JavaScript knowledge
  • ▸Limited physics-based simulation (needs external libs)
  • ▸Performance can drop with very large DOM trees
  • ▸Animation sequencing for very complex apps can become verbose

When NOT to Use

  • ▸High-end 3D object animations (use Three.js or Babylon.js)
  • ▸Physics simulations (use Matter.js or Cannon.js)
  • ▸Very large DOM animations (>1000 elements)
  • ▸Server-side animation
  • ▸Animations that require GPU compute shaders

Cheat Sheet

  • ▸anime({ targets: '.box', translateX: 250 })
  • ▸anime.timeline({})
  • ▸anime({ targets, scale: 2, duration: 500, easing: 'easeInOutQuad' })
  • ▸timeline.add({ targets, opacity: [0,1] })
  • ▸anime.remove(targets) - stop animations

FAQ

  • ▸Can Anime.js animate SVG? -> Yes, including paths
  • ▸Does Anime.js support timelines? -> Yes
  • ▸Can I use Anime.js with React/Vue/Angular? -> Yes
  • ▸Is Anime.js lightweight? -> Yes, ~14KB minified
  • ▸Does Anime.js require plugins? -> No, standalone library

30-Day Skill Plan

  • ▸Week 1: Simple element animations
  • ▸Week 2: SVG and path animations
  • ▸Week 3: Timelines and sequencing
  • ▸Week 4: Integrate with frameworks
  • ▸Week 5: Performance optimization and reusable utilities

Final Summary

  • ▸Anime.js is a versatile, lightweight animation library for web developers.
  • ▸Supports DOM, CSS, SVG, and JS object animations.
  • ▸Powerful timelines and easing enable complex sequences.
  • ▸Framework-agnostic and easy to integrate.
  • ▸Ideal for UI micro-interactions, web animations, and data visualization effects.

Project Structure

  • ▸index.html - DOM or SVG elements to animate
  • ▸main.js - anime.js scripts
  • ▸styles.css - optional CSS styling
  • ▸assets/ - images or SVGs used in animation
  • ▸utils/ - helper functions for animation logic

Monetization

  • ▸Enhanced landing page experiences for SaaS
  • ▸Interactive marketing pages
  • ▸Animated dashboards for paid analytics tools
  • ▸UI micro-interactions for premium apps
  • ▸SVG/Logo animation services for clients

Productivity Tips

  • ▸Use timelines for sequence control
  • ▸Group animations logically
  • ▸Reuse easing functions
  • ▸Cache selectors for performance
  • ▸Combine transforms and opacity for GPU acceleration

Basic Concepts

  • ▸Target - the element or object to animate
  • ▸Property - CSS, attribute, or JS property to animate
  • ▸Duration - time in milliseconds
  • ▸Easing - interpolation function for smooth motion
  • ▸Timeline - sequence multiple animations in order

Official Docs

  • ▸https://animejs.com/documentation/
  • ▸https://github.com/juliangarnier/anime

More Animejs Typing Exercises

Simple Anime.js AnimationBounce AnimationRotate AnimationScale PulseColor ChangeTranslate XYTimeline ExampleStaggered AnimationElastic Animation

Practice Other Languages

CReactPythonC++RustTypeScriptKotlinPHPJavaC#RubyMqlCqlN1qlCypher