Skip to content

如何实现1.x 工具栏里的全屏 #462

Answered by scarletfrank
scarletfrank asked this question in Q&A
Discussion options

You must be logged in to vote

大概写了一个实现,目前发现这种实现的问题在于全屏之后,加入的_MiniMap_组件消失了,以及目前我工具栏的写法不知道怎么实现点了按钮之后图标的SVG修改(即放大的图标和缩小的图标)

// App组件里定义
const graphRef = useRef(null);
// return() 里
<Graphin
  ref={graphRef}
>
   <Toolbar gRef={graphRef} />
/Graphin>
// 砍了很多代码,我这个Toolbar写法我记得也是issue里翻出来的,因为我是要在Graphin中使用G6
const Toolbar = (props) => {
  const { graph } = React.useContext(GraphinContext);
  const { updateState, state, gRef } = props;
  useEffect(() => {
    const toolbar = new G6.ToolBar({
      getContent: () => `
            <ul class='g6-component-toolbar'>
              <li code="fullscreen" title="全屏">
                <svg >
                </svg>
              </li>
            </ul>`,
      handleClick: (code, graph) 

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by scarletfrank
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants