Este artigo descreve o método da camada de controle JS fazendo movimento circular. Compartilhe -o para sua referência, como segue:
<! Doctype html public "-// w3c // dtd html 4.01 // pt" "http://www.w3.org/tr/html4/strict.dtd"><html><head> timta http-equiv =" Content-se " charset = utf-8 "> <title> movimento circular </title> <script type =" text/javascript "> window.onload = function () {var ctrlbtn = $ id (" ctrl "); var ismove = true; om = nulo; ctrlbtn.OnClick = function () {if (ismove) {moveByCircle (); } else {ClearInterval (OM); } ismove =! ismove; }} função moveByCircle () {var bacl = parseint ($ id ("clockbac"). style.left); var Bact = parseint ($ id ("clockbac"). style.top); var BACW = parseint ($ id ("clockbac"). style.width); var bach = parseint ($ id ("clockbac"). style.height); var initl = BACL+BACW/2; var initt = bact+bach/2; var stage = 0; var r = 65; $ id ("tt"). style.left = initl+"px"; $ id ("tt"). style.top = initt+"px"; var L = parseint ($ id ("tt"). style.left); var t = parseint ($ id ("tt"). style.top); om = window.setInterval (function () {if (step == 360) {step = 1;} $ id ("tt"). style.left = (l + r * math.sin (step) + "px"; $ id ("tt"). style.top = (t - r * math.Cos (step)) + "px"; D.Gethours (); } função $ id (id) {return document.getElementById (id); } </script> </ad Head> <body> <div id = "tt" style = "width: 10px; altura: 10px; fundo: vermelho; posição: absoluto; topo: 105px; esquerda: 130px;"> </div> <input type = "button" = "ctrl" = "width: 100px; id = "clockbac" style = "width: 200px; altura: 200px; topo: 100px; esquerda: 100px; posição: absoluto; z-index: -999"/> </body> </html>For more information about JavaScript related content, please check out the topics of this site: "Summary of JavaScript switching effects and techniques", "Summary of JavaScript search algorithm skills", "Summary of JavaScript animation effects and techniques", "Summary of JavaScript errors and debugging techniques", "Summary of JavaScript data structures and algorithm skills", "Summary of Javascript Algoritmos e Técnicas de Traversal "e" Resumo do Uso do Javascript Mathematic Operations "
Espero que este artigo seja útil para a programação JavaScript de todos.