Hover only on non-transparent part of image

前端 未结 6 670
野性不改
野性不改 2020-12-07 02:25

Is there any way to make only a non-transparent portion of an image to trigger mouse-over event?

If the mouse travels to the transparent area, the mouse-out should b

6条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-07 02:52

    You could map out where the transparent portions of the image are (given this chroma-key example, I expect you could do this in client side code in some browsers) and then compare the position of the event on a mousemove event to see if the pointer is over the transparent portion or not. Then you just need to add a variable to track if it was over that portion last time you checked or not.

提交回复
热议问题