为了账号安全,请及时绑定邮箱和手机立即绑定

如何改变一个简单难题的方向

如何改变一个简单难题的方向

料青山看我应如是 2021-04-19 17:14:44
我正在努力使这个示例难题。我想改变方向,如果拼图触摸底部窗口,那么它将沿着右侧窗口像以前一样旋转,再次触摸右侧窗口后,它将移动到顶部窗口let delayInSecond = 1000; //1 secondlet squireElem = document.querySelector('.squire');let maxHeight = window.innerHeight;let posTop = 50;let posRight = 0;let posBottom = 0;let posLeft = 0;let timer = setInterval(squire, delayInSecond);function squire() {  let elemHeight = squireElem.offsetHeight;  if (maxHeight === elemHeight) {    clearInterval(timer);  } else {    posTop += 10;    posRight += 10;    posBottom += 10;    posLeft += 10;    squireElem.style.top = posTop + 'px';    squireElem.style.left = posLeft + 'px';  }}* {  margin: 0;  padding: 0;}.squire {  width: 100px;  height: 100px;  background-color: blue;  position: absolute;  top: 50px;}<div class="squire"></div>
查看完整描述

2 回答

  • 2 回答
  • 0 关注
  • 100 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信