Skip to content

Commit

Permalink
fix: combo states
Browse files Browse the repository at this point in the history
  • Loading branch information
baizn authored and Yanyan-Wang committed Aug 21, 2020
1 parent 5743df8 commit da48078
Show file tree
Hide file tree
Showing 4 changed files with 407 additions and 28 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
"site:deploy": "npm run site:build && gh-pages -d public",
"start": "npm run site:develop",
"test": "jest",
"test-live": "DEBUG_MODE=1 jest --watch ./tests/unit/state/update-element-states-spec.ts",
"lint-staged:js": "eslint --ext .js,.jsx,.ts,.tsx",
"watch": "father build -w",
"cdn": "antv-bin upload -n @antv/g6"
Expand Down
28 changes: 1 addition & 27 deletions src/item/item.ts
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,6 @@ export default class ItemBase implements IItemBase {
const group: Group = this.get('group');
const children = group.get('children');
const keyShape: IShapeBase = this.getKeyShape();

const self = this;

each(children, (child) => {
Expand Down Expand Up @@ -315,32 +314,7 @@ export default class ItemBase implements IItemBase {
}

if (currentShape) {
const styles: ShapeStyle & Indexable<any> = {};
// 这里要排除掉所有 states 中样式
const states = this.get('states');
states.map((state) => {
const style = this.getStateStyle(state);
for (const key in style) {
if (!isPlainObject(style[key])) {
if (!RESERVED_STYLES.includes(key)) {
RESERVED_STYLES.push(key);
}
} else {
const subStyle = style[key];
for (const subKey in subStyle) {
if (!RESERVED_STYLES.includes(subKey)) {
RESERVED_STYLES.push(subKey);
}
}
}
}
});
each(currentShape.attr(), (val, key) => {
if (RESERVED_STYLES.indexOf(key) < 0) {
styles[key] = val;
}
});
return styles;
return currentShape.attr();
}
return {};
}
Expand Down
4 changes: 3 additions & 1 deletion stories/Combo/combo.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import CreateCombo from './component/create-combo';
import RemoveItem from './component/remove-item';
import DragNodeOut from './component/drag-node-out';
import TreeGraphCreateCombo from './component/treegraph-create-combo';
import ComboState from './component/states-combo'

export default { title: 'Combo' };

Expand All @@ -38,4 +39,5 @@ storiesOf('Combo', module)
.add('create combo ', () => <CreateCombo />)
.add('remove item ', () => <RemoveItem />)
.add('drag node out', () => <DragNodeOut />)
.add('treegraph create combo', () => <TreeGraphCreateCombo />);
.add('treegraph create combo', () => <TreeGraphCreateCombo />)
.add('combo state', () => <ComboState />)
Loading

0 comments on commit da48078

Please sign in to comment.