this article describes the buffering effect of JS implementation. Share for you for your reference, specific as follows:

buffer needs to use numerical integration, to get up and up: Math.ceil () down to the Math.floor ()

moving speed slowly slow effect, the moving speed = (terminal position when the position before) / a

 <! DOCTYPE HTML UBLIC "-//W3C//DTD XHTML 1 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd" > < HTML xmlns= "http://www.w3.org/1999/xhtml" > <. Gt; < style> #div{width:150px; height:150px; background:#0C6; position:absolute; left:0; top:50px;}. N () {var BTN = document.getElementById ('btn'); btn.onclick = function () {speed = 0; move (500);}; btn2.onclick = function () {speed = 0; 0;}; {}; {} {{(}) / / change position, if left then e==500, upwards, or right, downwards, speed = (terminal position - current position) / a number e==500? Speed = Math.ceil ((e- (div.offsetLeft)) /30): speed = Math.floor (e- (div.offsetLeft)) = = / / reach, close the timer ClearInterval (time);} else {div.style.left = div.offsetLeft+speed+'px';}, 30); < /script> < body> < input type=. T; div id = "div2" > < /div> < /body> < /html> /body> click here to view the "X" > online demonstration effect. 

or the use of this station online HTML/js running tool test to see the running effect: http://tools.jb51.net/code/HtmlJsRun

more interested in JavaScript related content readers can view the site topic: JavaScript switching effects and skills summary , "JavaScript lookup algorithm skills summary ", ", JavaScript traversal algorithm and skill summary " and "JavaScript mathematical operation usage summary "

hoped this article is helpful to everyone.

that you may be interested in:


This concludes the body part

This paper fixed link:http://www.script-home.com/example-of-the-buffer-motion-effect-of-js-implementation.html | Script Home | +Copy Link

Article reprint please specify:Example of the buffer motion effect of JS implementation | Script Home

You may also be interested in these articles!