[英]Cart to Fly Uncaught TypeError: Cannot read property 'top' of undefined
I am trying to make a cart fly effect but I am getting an error and not sure why the top is being called undefined. 我正在尝试制作手推车飞行效果,但出现错误,并且不确定为什么顶部被称为未定义。 I am already able to add the product on the basket but the image just got stuck and appears randomly on screen instead of animation from the parent image to the cart upward 我已经可以将产品添加到购物篮中,但是图像被卡住并随机出现在屏幕上,而不是从父图像到购物车的动画
$('.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()
});
}
});
PS I am using Jquery 2.1.3 and jqueryui 1.11.2 PS我正在使用Jquery 2.1.3和jqueryui 1.11.2
已经弄清楚了,该元素在某些页面上丢失导致错误
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.