Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

absolutePositioned with objects nested in groups #7142

Closed
ShaMan123 opened this issue Jun 21, 2021 · 9 comments · Fixed by #7858
Closed

absolutePositioned with objects nested in groups #7142

ShaMan123 opened this issue Jun 21, 2021 · 9 comments · Fixed by #7858
Labels
stale Issue marked as stale by the stale bot

Comments

@ShaMan123
Copy link
Contributor

ShaMan123 commented Jun 21, 2021

Version

latest

Test Case

http://jsfiddle.net/2185reh6/19/

Information about environment

browser chrome

Steps to reproduce

Add an absolutePositioned clip path to an object inside a group

Expected Behavior

Clip path should be positioned relative to canvas, http://fabricjs.com/docs/fabric.Object.html#absolutePositioned

Actual Behavior

Because group manages it's own plane the clip path is relative to the group

@ShaMan123
Copy link
Contributor Author

ShaMan123 commented Jun 21, 2021

This is a part of the major problem that group creates on it's objects.

Related #7130 #6776

@ShaMan123
Copy link
Contributor Author

ShaMan123 commented Jun 21, 2021

I think the problem is that calcTransformMatrix is called from within the clipPath. This call is unaware of the context it is running in, meaning it doesn't know it is a clip path transformed to a relative plane, therefore, it can't account for the transform matrix of the containing object.

@i-prikot
Copy link

Hi. I think it works as intended.
http://jsfiddle.net/i_prikot/fgkyns8z/

@ShaMan123
Copy link
Contributor Author

@asturur
Copy link
Member

asturur commented Jul 4, 2021

this is a though one.
Both use cases are fine, and discerning between the 2 with more options is not that much convenient.
The absolute positioned idea was to be able to have a clipPath on the canvas that would influence only an object.

It is working as intented from what i can see in the fiddle, but the point is that it does not invalidate the group cache on movement.

Not sure if this in an edge case that deserve fixing or not.
https://jsfiddle.net/qzo7r3y9/
you can also just set objectCaching: false on the group when you create it.

@stale
Copy link

stale bot commented Jul 19, 2021

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale Issue marked as stale by the stale bot label Jul 19, 2021
@stale stale bot closed this as completed Jul 26, 2021
@ShaMan123
Copy link
Contributor Author

ShaMan123 commented Jul 31, 2021

I found a work around

            const __drawClipPath = fabric.Object.prototype._drawClipPath;
            fabric.util.object.extend(fabric.Object.prototype, {
                _drawClipPath: function (ctx: CanvasRenderingContext2D) {
                    __drawClipPath.call(this, ctx);
                    //  render stuff here
                }
                // consider overriding the following method as well:
               //  isCacheDirty: () => true
            })

Now I am able to render many clip paths with varying absolutePositioned value, nested in groups and what not.

@ShaMan123
Copy link
Contributor Author

fixed by the rewrite
https://codesandbox.io/s/0d1pbh
Once caching is resolved this is gone for good

@ShaMan123 ShaMan123 removed the stale Issue marked as stale by the stale bot label Feb 24, 2022
@ShaMan123 ShaMan123 reopened this Apr 9, 2022
@stale
Copy link

stale bot commented Apr 25, 2022

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale Issue marked as stale by the stale bot label Apr 25, 2022
@stale stale bot closed this as completed May 2, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stale Issue marked as stale by the stale bot
Projects
None yet
3 participants