jquery - Image Reveal on mousemove using translateX with gradient -


$(document).ready(function() {    var $window = $(window),      $overlay = $('.example2'),      rotation = 0,      transover = 0      $window.on('mousemove', function(event) {      transover = (event.pagex / $window.width() * 1720) - 690;      $overlay.css('transform', 'translatex(' + transover + 'px)');    });  });
.img-responsive {    display: block;    width: 100%;    height: auto;  }  .stopoverflow {    overflow-x: hidden;    overflow-y: hidden;  }  #container {    position: relative;    width: 500px;    height: 500px;  }  img {    top: 0;    left: 0;  }  .example3 {    position: relative;    z-index: -3;  }  .example2 {    position: absolute;    z-index: -2;    bottom: 0;    top: 0;  }  .example1 {    position: absolute;    z-index: -1;  }  }
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>    <div id="container" class="stopoverflow">    <img class="example1 img-responsive" src="http://i.imgur.com/ihbqh7o.png">    <img class="example2 img-responsive" src="http://i.imgur.com/0sbuslm.png">    <img class="example3 img-responsive" src="http://i.imgur.com/9t7zuhd.png">  </div>

so have 3 images(if there better way handle ears). effect need shower turning on. using 3 layers. top layer shower head. middle layer image gradient, , bottom water. images same size , set responsive.

the issue image gradient moves either little or left or right on different resolutions. sure because of values i'm using. need consistent across multiple sized monitors. mobile not issue. fiddle posted below

https://jsfiddle.net/5v0b7tl8/2/

so figured out looking @ codepen

http://blog.mediamonkfish.com/animating-css3-gradients-on-mouse-move/

i still used image, changing script this

$window.on('mousemove', function(event) {     transover = (event.pagex / $window.width() * 100);     $overlay.css('transform', 'translatex(' + transover + '%)');   }); 

that set use % of screen made consistent. @ least think did versus using set pixel amount.


Comments

Popular posts from this blog

Hatching array of circles in AutoCAD using c# -

ios - UITEXTFIELD InputView Uipicker not working in swift -

Python Pig Latin Translator -