Is there a way to detect a click only on the non-transparent part of an image?
That is, a click on a transparent part works as if pointer-events is set
to none and a click on a non-transparent part works as if pointer-events
is set to auto.
Is there a way to detect a click only on the non-transparent part of an image?
That is, a click on a transparent part works as if pointer-events is set to none and a click on a non-transparent part works as if pointer-events is set to auto.
On Sunday, March 26, 2023 at 5:43:12 PM UTC-5, Andrew Poulos wrote:
Is there a way to detect a click only on the non-transparent part of an image?
That is, a click on a transparent part works as if pointer-events is set to none and a click on a non-transparent part works as if pointer-events is set to auto.You can use css clip-path to define clickable areas.
<https://developer.mozilla.org/en-US/docs/Web/CSS/clip-path>
Example usage:
<https://codepen.io/mlhaufe/pen/YzOMOGv?editors=1100>
clicking on the clipped areas will not trigger an alert but the visible portions will
On Thursday, 30 March 2023 at 03:40:33 UTC+11, Michael Haufe (TNO)
wrote:
On Sunday, March 26, 2023 at 5:43:12 PM UTC-5, Andrew Poulos wrote:
Is there a way to detect a click only on the non-transparent partYou can use css clip-path to define clickable areas.
of an image?
That is, a click on a transparent part works as if pointer-events
is set to none and a click on a non-transparent part works as if
pointer-events is set to auto.
<https://developer.mozilla.org/en-US/docs/Web/CSS/clip-path>
Example usage:
<https://codepen.io/mlhaufe/pen/YzOMOGv?editors=1100>
clicking on the clipped areas will not trigger an alert but the
visible portions will
Thanks for the replies. Alas the image doesn't have regular shaped transparent parts and using a secondary canvas won't work as well as
I'd like.
| Sysop: | Keyop |
|---|---|
| Location: | Huddersfield, West Yorkshire, UK |
| Users: | 715 |
| Nodes: | 16 (2 / 14) |
| Uptime: | 147:41:11 |
| Calls: | 12,091 |
| Calls today: | 4 |
| Files: | 15,000 |
| Messages: | 6,517,544 |