后不能正常工作有一个函数调用我有我的变换图像旋转步骤中的第一时间,它被称为在最初的函数调用时不工作后的问题我的页面加载。每次在我构建的图表上更改任何值时,都会调用此函数。为了画一幅画,有两枚硬币从屏幕的顶部落下,然后旋转两次,然后落在一叠硬币上。取而代之的是,每次调用函数时,硬币只会从屏幕的顶部放下/添加动画。与图像旋转jQuery的动画第一个函数调用
<div id="secondCoin"><img class="coin" src="./images/one_coin.png" alt="Second Coin Drops" /></div>
<div id="firstCoin"><img class="coin" src="./images/one_coin.png" alt="First Coin Drops" /></div>
<div id="showCoins"><img class="coin-stack" src="./images/fullstack_coins.png" alt="Stack of Coins" /></div>
function coinStack(height){
var coinSound = document.getElementById('coin-sound');
var rotateDeg = 720;
// prevents sound play on multiple clicks
coinSound.pause();
coinSound.currentTime = 0;
// causes coin stack to slide upward
$("#showCoins").css("display", "inline-block");
$("#showCoins").css("top", height + "px");
screenWidth <= 400 ? $("#showCoins").stop().animate({top: '3'},1000) : $("#showCoins").stop().animate({top: '0'},1000);
// first coin drops
$("#firstCoin").css("display", "inline-block");
$("#firstCoin").css("top", "-324px");
$("#firstCoin").clearQueue().delay(1000).animate({top: '10', deg: rotateDeg},{
duration: 350,
step: function(now){
$("#firstCoin").css({ transform: "rotate(" + now + "deg)" });
}
});
// second coin drops
$("#secondCoin").css("display", "inline-block");
$("#secondCoin").css("top", "-324px");
$("#secondCoin").clearQueue().delay(1400).animate({top: '0', deg: rotateDeg},{
duration: 350,
step: function(now){
$("#secondCoin").css({ transform: "rotate(" + now + "deg)" });
}
});
// coin sound effect
coinSound.volume = 1.0;
coinSound.play();
}
我使用.stop(尝试),.clearQueue(),设定/删除不同的变换属性,并检查了计算器的各种方法。似乎没有任何工作,所以我希望另一组眼睛会发现我的问题。提前致谢!
难道你在控制台的任何错误,你可以给我们的HTML代码,所以我们可以尝试一下? – Zorken17
控制台上没有出现任何错误,并且我会在稍后提供html。 – Jester
在这里一切都很好......你能再详细描述一下这个问题吗?我没有得到这个部分“而是像这样工作,每次调用函数时,硬币只会从屏幕的顶部放下/添加动画。”这就是所谓的行为...... – Salketer