Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

How to realize the Animation effect of bounce by JavaScript

Shulou Source: shulou.com Published: 2022-05-31 11:50:05 09月23日 Update

This article mainly explains "JavaScript how to achieve bounce animation effect", interested friends may wish to take a look. The method introduced in this paper is simple, fast and practical. Next let the editor to take you to learn "JavaScript how to achieve bounce animation effect" bar!

The code is as follows:

Document # box {width:200px; height:200px; position:absolute; top:0; left:200px; background:lightblue;} .btn {position:absolute; top:200px; left:100px; height:50px;} .btn input {display:inline-block; margin-left:50px; outline: none; width:100px Height:50px; border:1px solid green; cursor:pointer;} var oBox = document.getElementById ("box"); var minLeft = 0; var maxLeft = utils.win ('clientWidth')-oBox.offsetWidth; var step = 5; var timer = null; function move (target) {/ / target: tell me the target position to move window.clearTimeout (timer) Var curLeft = utils.css (oBox, "left"); if (curLefttarget) {/ / Border utils.css (oBox, "left", target); return;} curLeft+=step; utils.css (oBox, "left", curLeft)} else if (curLeft > target) {/ / left if (curLeft-steptarget) {/ / left if (curLeft-step)

Tags: Animation function action boundary element timer time private motion effect code problem bad position global content package variable go left attribute Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Tech Info Docker MySQL MariaDB Apple