All Projects → VitorLuizC → animate

VitorLuizC / animate

Licence: MIT license
👾 Create and manage animation functions with AnimationFrame API.

Programming Languages

typescript
32286 projects
javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to animate

raf-perf
RAF loop with an adaptive fps and performance ratio calculated from either a sample count or a sample duration. Typically used when doing intensive graphics computation in canvas.
Stars: ✭ 40 (+263.64%)
Mutual labels:  loop, requestanimationframe
Ructe
Rust Compiled Templates with static-file handling
Stars: ✭ 206 (+1772.73%)
Mutual labels:  loop
Ppipe
A simple and lightweight Rust library for making iterator pipelines concurrent
Stars: ✭ 13 (+18.18%)
Mutual labels:  loop
Dottask
Simple and easy go task framework, support loop & cron & queue
Stars: ✭ 124 (+1027.27%)
Mutual labels:  loop
Swiftysound
SwiftySound is a simple library that lets you play sounds with a single line of code.
Stars: ✭ 995 (+8945.45%)
Mutual labels:  loop
Processingstuff
Various pretty-ish Processing sketches by Blokatt. About 50% shaders.
Stars: ✭ 153 (+1290.91%)
Mutual labels:  loop
Fast Cgi Client
A PHP fast CGI client for sending requests (a)synchronously to PHP-FPM
Stars: ✭ 478 (+4245.45%)
Mutual labels:  loop
executor
Gnome Shell Extension - Execute multiple shell commands periodically with separate intervals and display the output in gnome top bar.
Stars: ✭ 45 (+309.09%)
Mutual labels:  interval
Patches
Patches is a visual programming editor for building WebVR and WebGL experiences.
Stars: ✭ 164 (+1390.91%)
Mutual labels:  loop
Akvideoimageview
UIImageView subclass that allows you to display a looped video and dynamically switch it.
Stars: ✭ 123 (+1018.18%)
Mutual labels:  loop
Service
Service encapsulates an object which executes a bit of code in a loop that can be started or stopped and query whether it is running or not.
Stars: ✭ 86 (+681.82%)
Mutual labels:  loop
Bentools Etl
PHP ETL (Extract / Transform / Load) library with SOLID principles + almost no dependency.
Stars: ✭ 45 (+309.09%)
Mutual labels:  loop
Pyicp Slam
Full-python LiDAR SLAM using ICP and Scan Context
Stars: ✭ 155 (+1309.09%)
Mutual labels:  loop
Superboucle
Loop application synced with jack transport
Stars: ✭ 31 (+181.82%)
Mutual labels:  loop
MatlabProgressBar
This MATLAB class provides a smart progress bar like tqdm in the command window and is optimized for progress information in simple iterations or large frameworks with full support of parallel parfor loops provided by the MATLAB Parallel Computing Toolbox.
Stars: ✭ 44 (+300%)
Mutual labels:  loop
React Text Loop
Animate words in your headings
Stars: ✭ 595 (+5309.09%)
Mutual labels:  loop
Infinite Uicollectionview
Make a UICollectionView infinitely scrolling by looping through content
Stars: ✭ 82 (+645.45%)
Mutual labels:  loop
Docxtemplater
Generate docx pptx and xlsx (Microsoft Word, Powerpoint, Excel documents) from templates, from Node.js, the Browser and the command line / Demo: https://www.docxtemplater.com/demo
Stars: ✭ 1,990 (+17990.91%)
Mutual labels:  loop
any-scroll
🚀 模拟scrollview, 支持pc/移动端, 让实现Tab/Slider等组件轻而易举.
Stars: ✭ 45 (+309.09%)
Mutual labels:  requestanimationframe
ViewWorld
自定义View合集,展示各种自定义View/控件。项目包含了自定义Banner轮播图控件,自定义验证码输入框,自定义TabLayout等控件,持续更新中😉😉😉
Stars: ✭ 94 (+754.55%)
Mutual labels:  loop

@bitty/animate

License Library minified size Library minified + gzipped size

Animate bubbles example GIF

Create and manage animation functions with AnimationFrame API.

  • Dependency free and smaller than 170B (ESM minified + gzipped);
  • 🏷️ Type definitions to TS developers and IDE/Editors intellisense;
  • 📦 CommonJS, ESM and UMD distributions (CDN uses UMD as default);

See bubbles example at Codepen

Installation

This library is published in the NPM registry and can be installed using any compatible package manager.

npm install @vitorluizc/animate --save

# For Yarn, use the command below.
yarn add @vitorluizc/animate

Installation from CDN

This module has an UMD bundle available through JSDelivr and Unpkg CDNs.

<script src="https://cdn.jsdelivr.net/npm/@bitty/animate"></script>

<script>
  // module will be available through `animate` function.

  var animation = animate(function () {
    // ...
  });

  animation.start();
</script>

Usage

Call animate, the default exported function, with your callback and use returned object to manage your animation.

import animate from '@bitty/animate';

const canvas = document.querySelector('canvas');
const context = canvas.getContext('2d');
const position = { x: 0, y: 0 };

const animation = animate(() => {
  context.clearRect(0, 0, canvas.width, canvas.height);
  context.beginPath();
  context.arc(position.x, position.y, 100 / 2, 0, 2 * Math.PI);
  context.fillStyle = '#000000';
  context.fill();
  context.closePath();
});

window.addEventListener('mousemove', (event) => {
  position.x = event.clientX;
  position.y = event.clientY;
});

animation.start();

See this example on Codepen.

API

  • animate

    The default exported function, which receives callback as argument and returns an Animation.

    • callback is a synchronous function running into a AnimationFrame recursion.
    let count = 0;
    
    const animation = animate(() => {
      context.clearRect(0, 0, element.width, element.height);
      context.font = '4rem monospace';
      context.textAlign = 'center';
      context.fillText(count, element.width / 2, element.height / 2);
    
      count++;
    });
    
    animation.start();

    See this example on Codepen.

    TypeScript type definitions.
    export default function animate(callback: () => void): Animation;
  • Animation

    An object returned by animate function to manage your animations. It can start, stop and check if animation is running.

    • running: A getter property that indicates if animation is running.

    • start(): A method to start the animation.

    • stop(): A method to stop the animation.

    const animation = animate(() => { ... });
    
    animation.start();
    
    // Stops the animation after 10s
    setTimeout(() => animation.stop(), 10 * 1000);
    
    if (animation.running)
      console.log('The animation is running...');
    TypeScript type definitions.
    export interface Animation {
      readonly running: boolean;
      stop: () => void;
      start: () => void;
    }

License

Released under MIT License.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].