Skip to content

Commit

Permalink
fix: handle warnings of lgtm.com
Browse files Browse the repository at this point in the history
  • Loading branch information
bubkoo committed Dec 10, 2019
1 parent 7caa5e5 commit 22c054f
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 14 deletions.
20 changes: 9 additions & 11 deletions examples/x6-example-drawio/src/pages/graph/format-cell.tsx
Expand Up @@ -296,7 +296,7 @@ export class FormatCell extends React.PureComponent<
)}
className="x6-editor-format-number right"
formatter={value => `${value!}%`}
parser={value => value!.replace('%', '')}
parser={value => value!.replace(/%$/g, '')}
style={{ flex: 1 }}
/>
)}
Expand Down Expand Up @@ -535,21 +535,19 @@ export class FormatCell extends React.PureComponent<
toggleItalic = () => {
this.executeCommand('italic')
const current = (this.state.fontStyle as number) || 0
this.setState({
fontStyle: FontStyle.isItalic(this.state.fontStyle)
? current - FontStyle.italic
: current + FontStyle.italic,
})
const fontStyle = FontStyle.isItalic(this.state.fontStyle)
? current - FontStyle.italic
: current + FontStyle.italic
this.setState({ fontStyle })
}

toggleUnderline = () => {
this.executeCommand('underline')
const current = (this.state.fontStyle as number) || 0
this.setState({
fontStyle: FontStyle.isUnderlined(this.state.fontStyle)
? current - FontStyle.underlined
: current + FontStyle.underlined,
})
const fontStyle = FontStyle.isUnderlined(this.state.fontStyle)
? current - FontStyle.underlined
: current + FontStyle.underlined
this.setState({ fontStyle })
}

onFontSizeChanged = (fontSize?: number) => {
Expand Down
4 changes: 2 additions & 2 deletions packages/x6/src/route/er.ts
Expand Up @@ -95,14 +95,14 @@ export function er(
const targetGeometry = graph.getCellGeometry(targetState.cell)!
if (targetGeometry.relative) {
isTargetLeft = targetGeometry.bounds.x <= 0.5
} else if (sourceState != null) {
} else {
isTargetLeft =
sourceState.bounds.x + sourceState.bounds.width < targetState.bounds.x
}
}
}

if (sourceState != null && targetState != null) {
if (sourceState && targetState) {
const x0 = isSourceLeft
? sourceState.bounds.x
: sourceState.bounds.x + sourceState.bounds.width
Expand Down
3 changes: 2 additions & 1 deletion packages/x6/src/route/loop.ts
Expand Up @@ -69,7 +69,8 @@ export function loop(
x = sourceState.bounds.x + sourceState.bounds.width + 2 * dy
}
}
} else if (pt != null) {
} else {
// pt is not null
x = view.getRoutingCenterX(sourceState)
dx = Math.max(Math.abs(x - pt.x), dy)
y = pt.y
Expand Down

0 comments on commit 22c054f

Please sign in to comment.