Hi guys,
I’m normally pretty ok at JQuery but I need some help with the following code. It is to make the product image appear to fly across the screen and into the shopping cart when the user clicks buy.
It is functioning ok but I have changed the layout because I am customizing a template and now where it originally started to animate is not where I have repositioned it. You will see what I mean if you follow the hyperlink below:
http://www.wavemobilephones.com/index.php?route=product/product&path=60_64&product_id=1232
What I need to do is to be able to re-position where the product image flies off from so I would appreciate either a rework of the code or possibly suggesting a way in which I could slow down the process so that I can work it out for myself.
$('#add_to_cart').click(function () {
$.ajax({
type: 'post',
url: 'index.php?route=module/cart/callback',
dataType: 'html',
data: $('#product :input'),
success: function (html) {
$('#module_cart .middle').html(html);
},
complete: function () {
var image = $('#image').offset();
var cart = $('#module_cart').offset();
$('#image').before('<img src="' + $('#image').attr('src') + '" id="temp" style="position: absolute; top: ' + image.top + 'px; left: ' + image.left + 'px;" />');
params = {
top : cart.top + 'px',
left : cart.left + 'px',
opacity : 0.0,
width : $('#module_cart').width(),
height : $('#module_cart').height()
};
$('#temp').animate(params, 'slow', false, function () {
$('#temp').remove();
});
location.href = "http://www.wavemobilephones.com/index.php?route=checkout/cart";
}
});
});
thanks
Silversufer