Skip to content

Commit

Permalink
feat:add FontPaint behaviors
Browse files Browse the repository at this point in the history
  • Loading branch information
pomelo-nwu committed Jan 27, 2021
1 parent 0d0fe66 commit 9575d7b
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
21 changes: 21 additions & 0 deletions packages/graphin/src/behaviors/FontPaint.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import React from 'react';
import GraphinContext from '../GraphinContext';

const FontPaint = () => {
const { graph } = React.useContext(GraphinContext);
React.useEffect(() => {
// Hack 写法,解决第一次加载不绘制 ICON FONT 的 BUG
const timer = setTimeout(() => {
graph.getNodes().forEach((node) => {
graph.setItemState(node, 'normal', true);
});
graph.paint();
}, 1600);
return () => {
clearTimeout(timer);
};
}, []);
return null;
};

export default FontPaint;
2 changes: 2 additions & 0 deletions packages/graphin/src/behaviors/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import DragCombo from './DragCombo';
import ActivateRelations from './ActivateRelations';
import Hoverable from './Hoverable';
import FitView from './FitView';
import FontPaint from './FontPaint';

export default {
TreeCollapse,
Expand All @@ -24,4 +25,5 @@ export default {
ActivateRelations,
Hoverable,
FitView,
FontPaint,
};

0 comments on commit 9575d7b

Please sign in to comment.