mirror of
https://github.com/n8n-io/n8n.git
synced 2024-12-29 06:29:42 -08:00
refactor func
This commit is contained in:
parent
9a39c655f8
commit
a822539195
|
@ -278,23 +278,7 @@ export default mixins(
|
|||
};
|
||||
},
|
||||
backgroundStyle (): object {
|
||||
const scale = this.nodeViewScale;
|
||||
const offsetPosition = this.$store.getters.getNodeViewOffsetPosition;
|
||||
const squareSize = 20 * scale;
|
||||
const dotSize = 1 * scale;
|
||||
const dotPosition = 10 * scale;
|
||||
const styles: object = {
|
||||
'background-size': `${squareSize}px ${squareSize}px`,
|
||||
'background-position': `left ${offsetPosition[0]}px top ${offsetPosition[1]}px`,
|
||||
};
|
||||
if (squareSize > 10.5) {
|
||||
const dotColor = getStyleTokenValue('--color-canvas-dot');
|
||||
return {
|
||||
...styles,
|
||||
'background-image': `radial-gradient(circle at ${dotPosition}px ${dotPosition}px, ${dotColor} ${dotSize}px, transparent 0)`,
|
||||
};
|
||||
}
|
||||
return styles;
|
||||
return CanvasHelpers.getBackgroundStyles(this.nodeViewScale, this.$store.getters.getNodeViewOffsetPosition);
|
||||
},
|
||||
workflowClasses () {
|
||||
const returnClasses = [];
|
||||
|
|
|
@ -325,3 +325,21 @@ export const getRelativePosition = (x: number, y: number, scale: number, offset:
|
|||
(y - offset[1]) / scale,
|
||||
];
|
||||
};
|
||||
|
||||
export const getBackgroundStyles = (scale: number, offsetPosition: XYPosition) => {
|
||||
const squareSize = 20 * scale;
|
||||
const dotSize = 1 * scale;
|
||||
const dotPosition = 10 * scale;
|
||||
const styles: object = {
|
||||
'background-size': `${squareSize}px ${squareSize}px`,
|
||||
'background-position': `left ${offsetPosition[0]}px top ${offsetPosition[1]}px`,
|
||||
};
|
||||
if (squareSize > 10.5) {
|
||||
const dotColor = getStyleTokenValue('--color-canvas-dot');
|
||||
return {
|
||||
...styles,
|
||||
'background-image': `radial-gradient(circle at ${dotPosition}px ${dotPosition}px, ${dotColor} ${dotSize}px, transparent 0)`,
|
||||
};
|
||||
}
|
||||
return styles;
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue