我想在另一个动画 div 达到 100px
作为其左边距时更改 div 的上边距。我尝试在匿名函数中执行此操作,但它不起作用。
代码如下:
(function (){
"use strict";
var app = WinJS.Application;
var activation = Windows.ApplicationModel.Activation;
var animatedNumber;
app.onactivated = function (args) {
if (args.detail.kind === activation.ActivationKind.launch) {
if (args.detail.previousExecutionState !== activation.ApplicationExecutionState.terminated) {
animatedNumber = parseInt(Math.random()*10);
document.getElementById("animatedNumber").innerHTML = animatedNumber;
$("#animatedNumber").animate({ marginLeft: '900px' },1000);
if (parseInt($("#animatedNumber").css("marginLeft"))>= 100)
$("#A1").animate({ marginTop: '-=40px' })
} else {
// TODO: This application has been reactivated from suspension.
// Restore application state here.
}
args.setPromise(WinJS.UI.processAll());
}
};
app.oncheckpoint = function (args) {
};
app.start();
})();`
最佳答案
我做的很简单,试试这个。
代替
$("#animatedNumber").animate({
marginLeft: '900px'
}, 1000);
if (parseInt($("#animatedNumber").css("marginLeft")) >= 100) {
$("#A1").animate({
marginTop: '-=40px'
})
}
试试这个
$("#animatedNumber").animate({
marginLeft: '100px'
}, 150, function() {
// DO the margin top changes
$("#A1").animate({
marginTop: '-=40px'
});
//Now complete the rest of the animation
$(this).animate({
marginLeft: '800px'
}, 750);
});
关于jquery - 在检查某些 css 属性后,在 jquery 中动态更改 css 属性,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27751783/