I'm putting in an image reveal effect on my site but it doesn't seem to be working properly.
The site will have several categories that when clicked automatically load the category's pictures into a slideshow.
If you click any of the pictures in the slideshow a modal will pop up of that image with another image positioned underneath it.
As of now my my clip function is working but for some reason the clip is starting at 340px(thus making it so the full image shows because the image is 280px) as opposed to 0px and then moving in a range from 0-280px.
Can someone check my code and see what's wrong?
function reveal(event) {
event.target.previousElementSibling.style.clip = "rect(0px, "+(event.clientX-event.target.offsetLeft)+"px, 280px, 0px)";
}
.reveal{
width: 280px;
height: 280px;
border:#000 1px solid;
float:left;
margin:24px;
}
.reveal > img {
position:absolute;
}
.reveal > .modalimg2 {
clip:rect(0px, 140px, 280px, 0px); /* top, right, bottom, left */
}
.reveal > .activator{
position:absolute;
width:280px;
height:280px;
opacity:0;
cursor: e-resize;
}
<div id="myModal" class="modal">
<div class="modal-dialog">
<div class="modal-content">
<div class = "reveal">
<!-- Modal Content (The Image) -->
<img src="" id = "mimg" class = "modalimg" width = "280px" height = "280px">
<img src="" id = "mimg2" class = "modalimg2" width = "280px" height = "280px">
<div class = "activator" onmousemove = "reveal(event)"></div>
</div>
</div>
</div>
</div>