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

[Feature]: i think Group should support controlsVisibility as constructor second options ? #10298

Open
4 tasks done
vaynevayne opened this issue Nov 28, 2024 · 8 comments
Open
4 tasks done

Comments

@vaynevayne
Copy link

CheckList

  • I agree to follow this project's Code of Conduct
  • I have read and followed the Contributing Guide
  • I have searched and referenced existing issues, feature requests and discussions
  • I am filing a FEATURE request.

Description

currect is noly has

group.setControlsVisibility({
    tl: true,
    tr: true,
    bl: true,
    br: true,
  })
new Group([],{
controlsVisibility:{ // not work 
 tl: true,
    tr: true,
    bl: true,
},
tl: true, // not work 
})

Current State

no

Additional Context

no

@zhe-he
Copy link
Contributor

zhe-he commented Dec 2, 2024

new Group([],{
  _controlsVisibility:{
    tl: false,
    tr: false,
    bl: true,
    br: true
  },
})

@vaynevayne
Copy link
Author

thanks, Private attributes may be removed at any time. The style is not very good, right?

@zhe-he
Copy link
Contributor

zhe-he commented Dec 2, 2024

It is recommended to use custom controllers rather than simply showing or hiding elements.

import { controlsUtils,  Group } from "fabric";
Group.createControls = function() {
    const controls =  controlsUtils.createObjectDefaultControls();
    delete controls.tl; // If you don't need to 
    delete controls.tr; // If you don't need to 
    return { controls }
}

@asturur
Copy link
Member

asturur commented Dec 2, 2024

the controlVisibility object is one of the oldest fabricJS feature and was never part of the options.
What is the use case for having it in the options? are you exporting control visibility to JSON? or something else?

@vaynevayne
Copy link
Author

The product needs to turn off the rotation function and does not support rotation @asturur

@vaynevayne
Copy link
Author

  1. 如无必要, 勿增实体
  2. 不喜欢命令式代码
    @zhe-he

@asturur
Copy link
Member

asturur commented Dec 3, 2024

Wouldn't you just then delete the rotation control from the control set?
Just remove it no?

@vaynevayne
Copy link
Author

vaynevayne commented Dec 3, 2024

I did not use the fabric api directly, but packaged it as react-fabric.Therefore, it is inconvenient to move the underlying configuration
In addition, when I saw createControls, I felt like I was writing source code instead of using fabricjs. I personally felt that this method was not good
And this is a static method that affects all groups, right?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants