Advertisement
Guest User

Untitled

a guest
Apr 9th, 2020
216
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. $(document).ready(function(){
  2.  
  3.   // console.log("ready");
  4.  
  5.   const $project = $("div.project");
  6.  
  7.   $project.hover(function(){
  8.  
  9.     let $currentID = $(this).attr('id');
  10.     let path = `images/${ $currentID }.jpg`
  11.     // console.log( path );
  12.  
  13.     $(this).mousemove(function( event ){
  14.  
  15.       // console.log("x", event.pageX)
  16.       // console.log("y", event.pageY)
  17.  
  18.       let $img = $('<img />', {
  19.         class : 'image-overlay',
  20.         src : path
  21.       });
  22.  
  23.       $img.css({
  24.         position : 'absolute',
  25.         top : event.pageY,
  26.         left : event.pageX,
  27.         'z-index' : 1
  28.       });
  29.  
  30.       $img.appendTo('body');
  31.  
  32.     });
  33.  
  34.     $(this).mouseout(function(){
  35.       $('.image-overlay').remove();
  36.     });
  37.  
  38.   });
  39. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement