Ignore mouse interaction on overlay image
The best solution I've found is with CSS Styling:
#reflection_overlay {
background-image:url(../img/reflection.png);
background-repeat:no-repeat;
width: 195px;
pointer-events:none;
}
pointer-events
attribute works pretty good and is simple.
avoid mouse events on one div that is below another
Remove the pointer events from the link when the card has the class is-flipped
.
.card.is-flipped .front_button.link {
pointer-events: none;
}
var card = document.querySelector('.card');card.addEventListener( 'click', function() { card.classList.toggle('is-flipped');});
var link = document.querySelector('.link');link.addEventListener( 'click', function(e) {e.stopPropagation(); alert("link");});
body { font-family: sans-serif; }
.scene { width: 200px; height: 300px; border: 1px solid #CCC; margin: 40px 0; perspective: 600px;}
.card { width: 100%; height: 100%; transition: transform 1s; transform-style: preserve-3d; position: relative;}
.card.is-flipped { transform: rotateY(180deg);}
.card.is-flipped .front_button.link { pointer-events: none;}
.card__face { position: absolute; width: 100%; height: 100%; line-height: 260px; color: white; text-align: center; font-weight: bold; font-size: 40px; backface-visibility: hidden;}
.card__face--front { background: red;}
.card__face--back { background: blue; transform: rotateY(180deg);}
.front_button{ background:yellow; height:200px; width:100%; position:absolute; bottom:0px; left:0px; cursor: pointer;}
.link{ border:1px solid red; }
<div class="scene scene--card"> <div class="card"> <div class="card__face card__face--front"> <a class="front_button link"> text </a> </div> <div class="card__face card__face--back"> back </div> </div></div><p>Click card to flip.</p>
Related Topics
Why Is My Infinite Loop Blocking When It Is in an Async Function
What Are the Differences Between Deferred, Promise and Future in JavaScript
Difference Between Textcontent VS Innertext
How to Call Reduce on an Array of Objects to Sum Their Properties
Pick Random Property from a JavaScript Object
How to "Await" for a Callback to Return
Why Do Results Vary Based on Curly Brace Placement
Disabling and Enabling a HTML Input Button
Dynamically Set Property of Nested Object
Global Variables in JavaScript Across Multiple Files
Difference Between HTMLcollection, Nodelists, and Arrays of Objects
How to Mock an Es6 Module Import Using Jest
Redirect Parent Window from an Iframe Action
How to Get HTML Elements from an Object Tag