我想在另一个动画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 - 在jQuery中,检查某些css属性后动态更改css属性,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/27751783/