Skip to content

Instantly share code, notes, and snippets.

@robertknight
Created January 12, 2016 11:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save robertknight/8450c09b280564df03f9 to your computer and use it in GitHub Desktop.
Save robertknight/8450c09b280564df03f9 to your computer and use it in GitHub Desktop.
Test case for hit testing of inline elements containing children with transforms applied.
<body>
<ol>
<li>Hover the mouse over the space between 'World' and 'Test' below,
note that the cursor is <i>not</i> a pointer and clicking
in the space does not log a console message.</li>
<li>Hover the mouse over 'World', resulting in the #clickme
element's background being highlighted in red</li>
<li>Now repeat step (1) and notice that the #clickme:hover
selector <i>is</i> applied and clicking in the space does
log a console message</li>
</ol>
<hr>
<span id="clickme">
<span class="left">Hello</span>
<span>World</span>
<span class="right">Test</span>
</span>
<style>
#clickme {
cursor: pointer;
}
#clickme:hover {
background-color: red;
}
.left {
display: inline-block;
margin-right: 10px;
/* at least one child of the inline element
needs to have a transform applied to trigger
the effect
*/
transform: translateY(0px);
}
.right {
display: inline-block;
margin-left: 200px;
}
</style>
<script>
document.getElementById('clickme').addEventListener('click', function () {
console.log('element clicked');
});
</script>
</body>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment