var rotateVal = 0 // 旋转角度
var InterVal // 定时器
function conMusic(){
//var audio = document.querySelector("audio");
console.log(audio.paused)
if(audio.paused){
audio.play()
rotate()
console.log("播放")
}else{
audio.pause()
clearInterval(InterVal)
console.log("停止")
}
}
// 设置定时器
function rotate () {
InterVal = setInterval(function () {
console.log("aa")
var img = document.getElementById('img')
rotateVal += 5
// 设置旋转属性(顺时针)
img.style.transform = 'rotate(' + rotateVal + 'deg)'
// 设置旋转属性(逆时针)
//img.style.transform = 'rotate(-' + rotateVal + 'deg)'
// 设置旋转时的动画 匀速0.1s
img.style.transition = '0.1s linear'
}, 100)
}
- THE END -
最后修改:2020年11月2日
非特殊说明,本博所有文章均为博主原创。