Home > Web Front-end > JS Tutorial > body text

用JavaScript实现动画效果的方法_javascript技巧

WBOY
Release: 2016-05-16 17:28:17
Original
1076 people have browsed it

其实原理是很简单的,主要是使用了一个计时器函数,下面我为大家
演示一个简单的动画的制作过程,通过有关的介绍,大家可以举一反三,做出更多很炫的动画效果。
  这个实例的效果是点击网页上的“开始移动”按钮,则其中的指定图层就会从左到右移动,在这个过程中你点击“停止移动”按钮就会停止移动。

复制代码 代码如下:

  
  
  JavaScript Motion Sample
  

  
  

  
   
    
   
  
I can moving...

  

  


  
  
   
  

  这里主要使用了一个叫setTimeout(function, interval)函数,这个函数的参数格式为:
  第一个参数“function”为超时后调用的函数名,第二个参数“interval”为超时值,以微秒为单位。
  注意一点是如果要停止这个计时器,必须保存调用这个setTimeout()函数后的返回值,通过clearTimeout(id)函数来取消计时器。
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!