本文实例讲述了JavaScript缓冲运动实现方法。分享给大家供大家参考,具体如下:
实现原理:(目标距离-当前距离) / 基数 = 速度(运动距离越大速度越小,运动距离和速度成反比)
(500 - oDiv.offsetLeft) / 7 = iSpeed;
需要注意:当计算出来的速度有小数时需要取整;
(500 - oDiv.offsetLeft) / 7 = iSpeed; iSpeed = iSpeed>0?Math.ceil(iSpeed):Math.floor(iSpeed);
例子1:滑块缓冲运动
例子2:侧边栏滑动
更多关于JavaScript运动效果相关内容可查看本站专题:《JavaScript运动效果与技巧汇总》
希望本文所述对大家JavaScript程序设计有所帮助。
Statement: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