The solution I'm after: to detect if a point falls within the red area below.
Now the difficulty here is that the red area isn't an image, it's actually a div that has been rotated into position.
Using JavaScript, how can I detect if a point lands in this area? And ideally in an efficient manner as this check might need to be called often and on slow devices.
CSS details: It has position: absolute on it, rotated 45 degrees and has been positioned using left: -135 and top:0.
My current approach has been to try and perform some calculation to determine where X intersects with the viewport, which will then give me Y (and I can calculate from there) but I have had no luck. Using getBoundingClientRect() on the element returns a square around the shape, but not of the shape itself.
How can this be done? Here is a small example (I want to detect if the top left corner of the intersecting element intersects with the red triangle):
body {
background: #ffd0ff;
padding: 12px;
margin: 0;
}
.sash {
position: absolute;
width: 270px;
height: 80px;
top: 0;
left: -135px;
background-color: #e10a0a;
opacity: 0.5;
transform: rotate(-45deg);
}
.intersection {
background: rgba(0, 255, 0, 0.5);
padding: 12px;
display: inline-block;
}
<div class="sash"></div>
<span class="intersection">
Some intersecting div
</span>

