如何实现1.x 工具栏里的全屏 #462
Answered
by
scarletfrank
scarletfrank
asked this question in
Q&A
-
目前了解的情报
P.S. 今天刚看到GraphInsight可以用了,看到有个Neo4j开箱即用的案例,下周体验下。也许下个项目我可以试着用GraphInsight |
Beta Was this translation helpful? Give feedback.
Answered by
scarletfrank
Dec 5, 2022
Replies: 2 comments
-
大概写了一个实现,目前发现这种实现的问题在于全屏之后,加入的_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) => {
switch (code) {
case 'fullscreen':
if (document.fullscreenElement) {
document.exitFullscreen();
message.info('退出全屏模式');
} else {
gRef.current.graphDOM.requestFullscreen();
message.info('进入全屏模式');
}
// console.log(gRef.current.graphDOM);
break;
}
},
});
graph.addPlugin(toolbar);
return () => {
if (toolbar && !toolbar.destroy) {
graph.destroy();
graph.removePlugin(toolbar);
}
};
});
return null;
};
export default Toolbar; |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
scarletfrank
-
@scarletfrank GraphInsight 体验的如何啦 |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
大概写了一个实现,目前发现这种实现的问题在于全屏之后,加入的_MiniMap_组件消失了,以及目前我工具栏的写法不知道怎么实现点了按钮之后图标的SVG修改(即放大的图标和缩小的图标)