Guest User

Untitled

a guest
Jul 21st, 2018
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.99 KB | None | 0 0
  1. $(document).ready(function(){
  2. var over = false;
  3. $("#map img").each(function() {
  4. var image_width = this.width;
  5. var width_change = Math.round(image_width + (image_width*5/100));
  6. $(this).mouseenter(function(){
  7. if (over === true)
  8. {setTimeout(function()
  9. {
  10. if (over === false)
  11. {
  12. over = true;
  13. clearTimeout($(this).data('timeoutId'));
  14. $(this).animate({width: width_change}, 1000);
  15. }
  16. }, 3000);}
  17. else
  18. {
  19. over = true;
  20. clearTimeout($(this).data('timeoutId'));
  21. $(this).animate({width: width_change}, 1000);
  22. }
  23. }).mouseleave(function(){
  24. var someelement = this;
  25. var timeoutId = setTimeout(function(){ $(someelement).animate({width: image_width});over = false;}, 3000);
  26. $(someelement).data('timeoutId', timeoutId); //set the timeoutId, allowing us to clear this trigger if the mouse comes back over
  27. });
  28. });
  29. });
Add Comment
Please, Sign In to add comment