$(document).ready(function() {
var mousePos = {};
$(window).mousemove(function(e) {
mousePos.x = e.pageX;
mousePos.y = e.pageY;
});
$(window).mouseleave(function(e) {
mousePos.x = 0;
mousePos.y = 0;
});
setInterval(function() {
if (mousePos.x > 0 && mousePos.y > 0) {
var color = "background: #000;";
size = "height: 40px; width:40px;";
var left = "left: " + (mousePos.x - 20) + "px;";
var top = "top: " + (mousePos.y - 15) + "px;";
var style = left + top + color + size;
$("<div class='ball' style='" + style + "'></div>")
.appendTo("#wrap")
.one(
"webkitAnimationEnd mozAnimationEnd MSAnimationEnd oanimationend animationend",
function() {
$(this).remove();
}
);
}
}, 5);
});
.bodies {
display: flex;
}
.bodies * {
position: absolute;
height: 40vh;
}
html,
body {
height: 100%;
margin: 0;
position: relative;
}
#wrap {
width: 100%;
height: 100%;
position: relative;
}
.ball {
pointer-events: none;
position: absolute;
border-radius: 50%;
animation: implode 2s 0.4s ease-in-out;
animation-fill-mode: both;
}
@keyframes implode {
100% {
transform: scale(0);
}
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div id="wrap">
<div class="bodies">
<img src="./Images/Blood.jpg" alt="" />
<img src="./Images/Body.jpg" alt="" />
</div>
</div>
This is my code for when I hover over the screen it creates div elements to display an animation type of effect with the circles. I just want to hide the image which is on the top of the second image when is hovered only over the specific area.
I just have this image on my mind where the green slide is the image below and the yellow one above and the green hole is the part hovered which shows the below image
CSS background on #wrap and .bodies place a :hover pseudo-class on .bodies.
$(document).ready(function() {
var mousePos = {};
$(window).mousemove(function(e) {
mousePos.x = e.pageX;
mousePos.y = e.pageY;
});
$(window).mouseleave(function(e) {
mousePos.x = 0;
mousePos.y = 0;
});
setInterval(function() {
if (mousePos.x > 0 && mousePos.y > 0) {
var color = "background: rgb(138, 3, 3);";
size = "height: 40px; width:40px;";
var left = "left: " + (mousePos.x - 20) + "px;";
var top = "top: " + (mousePos.y - 15) + "px;";
var style = left + top + color + size;
$("<div class='ball' style='" + style + "'></div>")
.appendTo("#wrap")
.one(
"webkitAnimationEnd mozAnimationEnd MSAnimationEnd oanimationend animationend",
function() {
$(this).remove();
}
);
}
}, 5);
});
.bodies {
display: flex;
}
.bodies * {
position: absolute;
height: 40vh;
}
html,
body {
height: 100%;
margin: 0;
position: relative;
}
#wrap {
width: 100%;
height: 100%;
position: relative;
background-image: url(https://cdn.picpng.com/blood/blood-picture-39852.png);
background-color: black;
background-repeat: no-repeat;
background-position: center center;
background-size: cover;
}
.bodies {
position:absolute;
top: 25%;
left: 25%;
width: 50%;
min-height: 50%;
border-radius: 50%;
background-color: transparent;
background-image: url(https://longreadsblog.files.wordpress.com/2018/07/laura-palmer.jpg );
background-repeat: no-repeat;
background-position: center center;
background-size: contain;
}
.bodies:hover {
transition: all 0.5s;
opacity: 0;
}
.ball {
pointer-events: none;
position: absolute;
border-radius: 50%;
animation: implode 2s 0.4s ease-in-out;
animation-fill-mode: both;
}
@keyframes implode {
100% {
transform: scale(0);
}
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div id="wrap">
<div class="bodies">
</div>
</div>