Skip to content

Commit 8a6b082

Browse files
authored
fix(GcodePreview): reset only null coordinates (#1775)
Signed-off-by: Pedro Lamas <[email protected]>
1 parent 639414b commit 8a6b082

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

src/store/gcodePreview/getters.ts

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,10 +120,23 @@ export const getters = {
120120
z: NaN
121121
}
122122

123-
for (let i = moveIndex; i >= 0 && (Number.isNaN(output.x) || Number.isNaN(output.y) || Number.isNaN(output.z)); i--) {
123+
for (let i = moveIndex, count = 0; i >= 0 && count < 3; i--) {
124124
const move = moves[i]
125125

126-
Object.assign(output, move)
126+
if (Number.isNaN(output.x) && move.x != null) {
127+
output.x = move.x
128+
count++
129+
}
130+
131+
if (Number.isNaN(output.y) && move.y != null) {
132+
output.y = move.y
133+
count++
134+
}
135+
136+
if (Number.isNaN(output.z) && move.z != null) {
137+
output.z = move.z
138+
count++
139+
}
127140
}
128141

129142
return {

0 commit comments

Comments
 (0)