Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Fly to cart effect - generic image

Tried searching everywhere but couldn't find a solution, so here goes.

Based on the following script - http://codepen.io/ElmahdiMahmoud/pen/tEeDn

Rather than have an image that has rendered on the page to fly to the basket, how can I override this with a generic image say this for example: http://lorempixel.com/400/200/ ---- the path I will use will be to an images folder.

like image 719
user3729157 Avatar asked Dec 14 '25 13:12

user3729157


1 Answers

I have found the best solution for jQuery fly to cart effect from here - Fly to cart effect using jQuery Uses of this script is very simple like the below.

$(document).ready(function(){
   $('.add-to-cart').on('click',function(){
       //Scroll to top if cart icon is hidden on top
       $('html, body').animate({
          'scrollTop' : $(".cart_anchor").position().top
       });
       //Select item image and pass to the function
       var itemImg = $(this).parent().find('img').eq(0);
       flyToElement($(itemImg), $('.cart_anchor'));
   });
});
like image 69
JoyGuru Avatar answered Dec 19 '25 06:12

JoyGuru



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!