Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

requestAnimationFrame

NotificationsYou must be signed in to change notification settings

component/raf

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

request animation frame

Installation

$ component install component/raf

Example

Request the animation frame withraf(fn), cancel withraf.cancel(id).

varx=0;vary=50;varcanvas=document.querySelector('canvas');varctx=canvas.getContext('2d');varraf=require('raf');functionanimate(){raf(animate);draw();}varprev=Date.now();functiondraw(){varcurr=Date.now();vardiff=curr-prev;varp=diff/16;ctx.clearRect(0,0,900,300);ctx.beginPath();ctx.globalAlpha=.5;ctx.arc(x,y,10,0,Math.PI*2,false);ctx.fill();x+=2;y+=Math.sin(x/20)*5;prev=curr;}animate();

License

MIT


[8]ページ先頭

©2009-2025 Movatter.jp