【发布时间】:2017-11-30 19:25:58
【问题描述】:
我正在尝试制作购物车飞行效果,但我收到一个错误,不知道为什么顶部被称为未定义。我已经能够将产品添加到购物篮中,但图像卡住并随机出现在屏幕上,而不是从父图像向上移动到购物车的动画
$('.add').on('click', function () {
var cart = $('.cart');
var imgtodrag = $('.zoomImg');
if (imgtodrag) {
var imgclone = imgtodrag.clone()
.offset({
top: imgtodrag.offset().top,
left: imgtodrag.offset().left
})
.css({
'opacity': '0.5',
'position': 'absolute',
'height': '150px',
'width': '150px',
'z-index': '100'
})
.appendTo($('body'))
.animate({
'top': cart.offset().top + 10,
'left': cart.offset().left + 10,
'width': 75,
'height': 75
}, 1000, 'easeInOutExpo');
setTimeout(function () {
cart.effect("shake", {
times: 2
}, 200);
}, 1500);
imgclone.animate({
'width': 0,
'height': 0
}, function () {
$(this).detach()
});
}
});
附: 我正在使用 Jquery 2.1.3 和 jqueryui 1.11.2
【问题讨论】:
标签: javascript jquery html css jquery-ui