Top Related Projects
GSAP (GreenSock Animation Platform), a JavaScript animation library for the modern web
JavaScript animation engine
The motion graphics toolbelt for the web
Tools for smoother shape animations.
The most versatile JavaScript typewriter effect library on the planet.
JavaScript library to make drawing animation on SVG
Quick Overview
Scene.js is a JavaScript animation library that allows developers to create complex animations using a timeline-based approach. It provides a powerful and flexible API for creating and managing animations, with support for various properties, easing functions, and keyframes.
Pros
- Intuitive timeline-based animation system
- Supports a wide range of CSS properties and transforms
- Provides fine-grained control over animation playback
- Lightweight and performant
Cons
- Learning curve for complex animations
- Limited built-in effects compared to some other animation libraries
- Documentation could be more comprehensive
- Smaller community compared to more established animation libraries
Code Examples
Creating a simple animation:
import Scene from "scenejs";
const scene = new Scene({
".box": {
0: {
width: "100px",
height: "100px",
backgroundColor: "#f00"
},
1: {
width: "200px",
height: "200px",
backgroundColor: "#00f"
}
}
});
scene.play();
Animating multiple properties with different durations:
const scene = new Scene({
".target": {
0: "opacity: 0; transform: translate(0px, 0px)",
1: {
opacity: 1,
},
2: {
transform: "translate(100px, 100px)",
},
}
}, {
duration: 2,
easing: "ease-in-out",
});
scene.play();
Using keyframes and custom easing:
import { Scene, Keyframes } from "scenejs";
const keyframes = new Keyframes({
0: {
width: "0%",
},
50: {
width: "80%",
},
100: {
width: "100%",
}
});
const scene = new Scene({
".progress-bar": {
0: {
width: "0%",
},
1: {
...keyframes.get(1),
}
}
}, {
easing: Scene.EASE_IN_OUT,
});
scene.play();
Getting Started
To use Scene.js in your project, first install it via npm:
npm install scenejs
Then, import and use it in your JavaScript file:
import Scene from "scenejs";
const scene = new Scene({
".element": {
0: { opacity: 0 },
1: { opacity: 1 }
}
});
scene.play();
For more advanced usage and options, refer to the official documentation.
Competitor Comparisons
GSAP (GreenSock Animation Platform), a JavaScript animation library for the modern web
Pros of GSAP
- More mature and feature-rich animation library with extensive documentation
- Larger community and ecosystem, providing better support and resources
- Cross-browser compatibility and optimized performance for complex animations
Cons of GSAP
- Paid licensing required for some advanced features and commercial use
- Steeper learning curve due to its extensive API and features
- Larger file size compared to SceneJS, which may impact load times
Code Comparison
GSAP:
gsap.to(".box", {
duration: 2,
x: 100,
y: 50,
rotation: 360,
ease: "power2.inOut"
});
SceneJS:
const scene = new Scene({
".box": {
0: { transform: "translate(0px, 0px) rotate(0deg)" },
2: { transform: "translate(100px, 50px) rotate(360deg)" }
}
}, {
easing: "ease-in-out"
});
scene.play();
Both libraries offer similar functionality for creating animations, but GSAP provides a more concise syntax and built-in easing functions. SceneJS uses a more declarative approach with keyframes and CSS-like properties. GSAP's extensive features and optimizations make it suitable for complex animations, while SceneJS offers a simpler, lightweight alternative for basic animation needs.
JavaScript animation engine
Pros of Anime
- Lightweight and fast, with a small file size
- Extensive documentation and examples
- Wide browser support, including older versions
Cons of Anime
- Limited to CSS properties and transforms
- Less flexible for complex, multi-object animations
- Lacks built-in timeline functionality
Code Comparison
Anime:
anime({
targets: '.element',
translateX: 250,
rotate: '1turn',
duration: 800,
easing: 'easeInOutQuad'
});
SceneJS:
const scene = new Scene({
".element": {
0: { transform: "translate(0px) rotate(0deg)" },
1: { transform: "translate(250px) rotate(360deg)" }
}
}, {
duration: 0.8,
easing: Scene.EASE_IN_OUT
});
scene.play();
SceneJS offers a more declarative approach with keyframes, while Anime uses a configuration object. SceneJS provides built-in timeline management, making it easier to create complex, multi-object animations. However, Anime's syntax is more concise for simple animations and may be easier for beginners to grasp.
Both libraries have their strengths, and the choice between them depends on the specific project requirements and the developer's preferences.
The motion graphics toolbelt for the web
Pros of mojs
- More comprehensive animation toolkit with a wider range of features
- Larger community and ecosystem with more resources and examples
- Better support for complex, multi-object animations
Cons of mojs
- Steeper learning curve due to its extensive API
- Larger file size, which may impact performance in some scenarios
- Less frequent updates and maintenance compared to SceneJS
Code Comparison
SceneJS:
import Scene from "scenejs";
const scene = new Scene({
".circle": {
0: "transform: translate(0px, 0px)",
1: "transform: translate(100px, 100px)",
},
});
scene.play();
mojs:
import mojs from '@mojs/core';
const circle = new mojs.Shape({
shape: 'circle',
scale: { 0: 1 },
duration: 1000,
easing: 'elastic.out'
}).play();
Both libraries offer declarative ways to create animations, but mojs provides more built-in shapes and easing functions, while SceneJS focuses on simpler, CSS-like syntax for animations.
Tools for smoother shape animations.
Pros of Flubber
- Specialized in shape morphing and interpolation
- Lightweight and focused on a specific task
- Easier to use for simple shape transformations
Cons of Flubber
- Limited to shape morphing, less versatile for general animations
- Fewer animation options and controls compared to SceneJS
Code Comparison
Flubber:
const interpolator = flubber.interpolate(shape1, shape2);
const intermediateShape = interpolator(0.5);
SceneJS:
const scene = new Scene({
[0]: { opacity: 0 },
1: { opacity: 1 },
2: { opacity: 0 },
}, {
duration: 2,
easing: "ease-in-out",
});
Key Differences
- Flubber focuses on shape morphing, while SceneJS is a more comprehensive animation library
- SceneJS offers a wider range of animation capabilities, including timelines and complex property animations
- Flubber is more suitable for specific shape-based transitions, while SceneJS is better for general-purpose animations
Use Cases
- Choose Flubber for simple shape morphing and interpolation tasks
- Opt for SceneJS when you need a full-featured animation library with timeline support and diverse property animations
The most versatile JavaScript typewriter effect library on the planet.
Pros of TypeIt
- Focused specifically on typing animations, making it easier to use for this purpose
- Lightweight and has no dependencies, resulting in a smaller bundle size
- Offers more customization options for typing animations, such as speed and cursor styles
Cons of TypeIt
- Limited to typing animations, while SceneJS offers a broader range of animation capabilities
- Less active development and community support compared to SceneJS
- Fewer integration options with other libraries or frameworks
Code Comparison
TypeIt:
new TypeIt("#element", {
strings: "This is a typing animation.",
speed: 50,
waitUntilVisible: true
}).go();
SceneJS:
import Scene from "scenejs";
const scene = new Scene({
"#element": {
0: "opacity: 0",
1: "opacity: 1"
}
}, {
duration: 2,
easing: "ease-in-out"
});
scene.play();
Summary
TypeIt is a specialized library for creating typing animations, offering simplicity and focused functionality. SceneJS, on the other hand, provides a more comprehensive animation toolkit with broader applications. The choice between the two depends on the specific project requirements and the desired range of animation capabilities.
JavaScript library to make drawing animation on SVG
Pros of Vivus
- Lightweight and focused specifically on SVG animation
- Simple API with minimal setup required
- Built-in options for different animation styles (delayed, sync, async, etc.)
Cons of Vivus
- Limited to SVG line drawing animations only
- Lacks advanced timeline controls and complex animation sequencing
- No support for non-SVG elements or properties
Code Comparison
Vivus:
new Vivus('my-svg', {duration: 200, type: 'delayed'}, myCallback);
Scene.js:
const scene = new Scene({
'.target': {
0: { opacity: 0 },
1: { opacity: 1 }
}
}, {
duration: 2,
easing: 'ease-in-out'
});
scene.play();
Scene.js offers more flexibility for animating various properties and elements, while Vivus focuses solely on SVG line drawing animations. Scene.js provides a more comprehensive animation framework with timeline controls, but may have a steeper learning curve compared to Vivus' simpler API for SVG animations.
Convert designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual CopilotREADME
Scene.js
ð¬ Scene.js is an JavaScript & CSS timeline-based animation library.
Official Site / API / Features / Examples / Main Project
ð Examples
- ClapperBoard Animation
- Panda eating Bamboo Animation
- Circle Burst
- Motion Effect
- Tree Animation
- Snow Animation
- Card Rotation
- Raindrop Effect
- Cube
- Shape
- Timer
âï¸ Installation
$ npm install scenejs
<script src="//daybrush.com/scenejs/release/latest/dist/scene.min.js"></script>
ð Documents
ð¦ Packages
Package | Version | Description |
---|---|---|
react-scenejs | A React Component that create JavaScript & CSS timeline-based animation with Scene.js. | |
svelte-scenejs | A Svelte Component that create JavaScript & CSS timeline-based animation with Scene.js. | |
vue-scenejs | A Vue 3 Component that create JavaScript & CSS timeline-based animation with Scene.js. | |
vue2-scenejs | A Vue 2 Component that create JavaScript & CSS timeline-based animation with Scene.js. | |
@scenejs/render | Make a movie of CSS animation through Scene.js. | |
@scenejs/effects | Effect collection library where you can add scene effects to Scene.js. | |
@scenejs/timeline | A library that represents the timeline of Scene.js. You can control time, properties, and items. | |
@scenejs/media | A library for playing or controlling media with Scene.js. | |
@scenejs/iframe | A library that control the animation of iframe with Scene.js. |
ð¬ Make Scene
import Scene from "scenejs";
const scene = new Scene({
".class": {
0: "left: 0px; top: 0px; transform: translate(0px);",
1: {
"left": "100px",
"top": "0px",
transform: "translate(50px)",
},
2: {
"left": "200px",
"top": "100px",
transform: {
translate: "100px",
},
}
}
}, {
selector: true,
easing: "ease-in-out",
}).play();
ð¬ Add Media (Audio/Video)
This library supports adding video and audio components to your scene. To add a video or an audio, you need to install @scenejs/media library.
Add necessary npm package
$ npm i @scenejs/media
How to use
import MediaScene from '@scenejs/media';
const mediaScene = new MediaScene();
mediaScene
.addMedia("background", "./background.mp3")
.seek(0, 40.79);
mediaScene
.addMedia("video", "./video.mp4")
.seek(0, 40.79)
.setVolume(1)
.setPlaySpeed(1)
.setDelay(startTime);
scene.setItem("video",mediaScene);
Please note that this library uses the built-in capability of your browser to play audio and video files. Make sure necessary codecs are installed, and the browser supports the video/audio file being added to the project
⨠Effects
- typing
- flip
- flipX
- flipY
- shake
- shakeX
- shakeY
- wipeIn
- wipeOut
- zoomIn
- zoomOut
- blink
- fadeIn
- fadeOut
- transition
ð Supported Browsers
Internet Explorer | Chrome | FireFox | Safari | Opera |
---|---|---|---|---|
9+(10+ playCSS) | latest | latest | latest | latest |
âï¸ Show Your Support
Please give a âï¸ if this project helped you!
ð Contributing
If you have any questions or requests or want to contribute to scenejs
or other packages, please write the issue or give me a Pull Request freely.
Code Contributors
This project exists thanks to all the people who contribute. [Contribute].
Sponsors
ð Bug Report
If you find a bug, please report to us opening a new Issue on GitHub.
ð License
This project is MIT licensed.
MIT License
Copyright (c) 2016 Daybrush
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
Top Related Projects
GSAP (GreenSock Animation Platform), a JavaScript animation library for the modern web
JavaScript animation engine
The motion graphics toolbelt for the web
Tools for smoother shape animations.
The most versatile JavaScript typewriter effect library on the planet.
JavaScript library to make drawing animation on SVG
Convert designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual Copilot