简体   繁体   中英

Clip selection area to ClipTo - Fabric JS

I am currently using Fabric.js for a web application that allows users to input and manipulate the canvas objects in a structured way.

One of our mechanisms for providing structure is to have 'bounding boxes' into which a user can place an image. When an image is placed into these, they can be panned and zoomed, but are clipped to the original bounding box's size and location.

Example: A clipped image

Here we see the clipped area, with its controls visible outside of it's clipped zone.

This is fine. The user can pan the image around, and the clipping box stays static. We are find with this.

However, if the client adds another image, and this image is underneath the area where the first image spans (but is not visible due to clipping) we cannot select the second object.

Example:

A selection obscured, clipped image

Here the face image is underneath where the golf image extends, outside of its clip range. The face image is not selectable without deselecting. One can imagine that if all three are here, it's possible to permanently obscure the selection area of the face image, without moving the other two images to reach it.

Turns out this is a feature of perPixelTargetFind, and I wasn't aware, I assumed it would only work for png transparency, not clipping transparency.

So if you are also facing this issue, simply turn on perpixeltargetfind, and you will probably solve your problem.

Thanks!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM