|
124 | 124 | <LayoutCol :class="'bar-area'">
|
125 | 125 | <PersistentScrollbar
|
126 | 126 | :direction="ScrollbarDirection.Vertical"
|
127 |
| - :handlePosition="scrollbarYPos" |
| 127 | + :handlePosition="scrollbarPos.y" |
128 | 128 | @update:handlePosition="translateCanvasY"
|
129 |
| - v-model:handleLength="scrollbarYSize" |
| 129 | + v-model:handleLength="scrollbarSize.y" |
130 | 130 | :class="'right-scrollbar'"
|
131 | 131 | />
|
132 | 132 | </LayoutCol>
|
133 | 133 | </LayoutRow>
|
134 | 134 | <LayoutRow :class="'bar-area'">
|
135 | 135 | <PersistentScrollbar
|
136 | 136 | :direction="ScrollbarDirection.Horizontal"
|
137 |
| - :handlePosition="scrollbarXPos" |
| 137 | + :handlePosition="scrollbarPos.x" |
138 | 138 | @update:handlePosition="translateCanvasX"
|
139 |
| - v-model:handleLength="scrollbarXSize" |
| 139 | + v-model:handleLength="scrollbarSize.x" |
140 | 140 | :class="'bottom-scrollbar'"
|
141 | 141 | />
|
142 | 142 | </LayoutRow>
|
@@ -305,11 +305,11 @@ export default defineComponent({
|
305 | 305 | },
|
306 | 306 | async translateCanvasX(newValue: number) {
|
307 | 307 | const { translate_canvas } = await wasm;
|
308 |
| - translate_canvas(-(newValue - this.scrollbarXPos) * (Math.abs(this.bounds.topX) + Math.abs(this.bounds.bottomX)), 0); |
| 308 | + translate_canvas(-(newValue - this.scrollbarPos.x) * this.scrollbarMultiplier.x, 0); |
309 | 309 | },
|
310 | 310 | async translateCanvasY(newValue: number) {
|
311 | 311 | const { translate_canvas } = await wasm;
|
312 |
| - translate_canvas(0, -(newValue - this.scrollbarYPos) * (Math.abs(this.bounds.topY) + Math.abs(this.bounds.bottomY))); |
| 312 | + translate_canvas(0, -(newValue - this.scrollbarPos.y) * this.scrollbarMultiplier.y); |
313 | 313 | },
|
314 | 314 | async selectTool(toolName: string) {
|
315 | 315 | const { select_tool } = await wasm;
|
@@ -343,21 +343,9 @@ export default defineComponent({
|
343 | 343 | registerResponseHandler(ResponseType.UpdateScrollbars, (responseData: Response) => {
|
344 | 344 | const updateData = responseData as UpdateScrollbars;
|
345 | 345 | if (updateData) {
|
346 |
| - this.bounds = updateData.bounds; |
347 |
| - const span = { x: Math.abs(updateData.bounds.bottomX - updateData.bounds.topX), y: Math.abs(updateData.bounds.bottomY - updateData.bounds.topY) }; |
348 |
| - const min = { x: Math.min(updateData.bounds.bottomX, updateData.bounds.topX), y: Math.min(updateData.bounds.bottomY, updateData.bounds.topY) }; |
349 |
| - if (span.x < updateData.viewport_size.x) { |
350 |
| - this.scrollbarXSize = 1; |
351 |
| - } else { |
352 |
| - this.scrollbarXPos = -min.x / (span.x - updateData.viewport_size.x); |
353 |
| - this.scrollbarXSize = updateData.viewport_size.x / span.x; |
354 |
| - } |
355 |
| - if (span.y < updateData.viewport_size.y) { |
356 |
| - this.scrollbarYSize = 1; |
357 |
| - } else { |
358 |
| - this.scrollbarYPos = -min.y / (span.y - updateData.viewport_size.y); |
359 |
| - this.scrollbarYSize = updateData.viewport_size.y / span.y; |
360 |
| - } |
| 346 | + this.scrollbarPos = updateData.position; |
| 347 | + this.scrollbarSize = updateData.size; |
| 348 | + this.scrollbarMultiplier = updateData.multiplier; |
361 | 349 | }
|
362 | 350 | });
|
363 | 351 | registerResponseHandler(ResponseType.ExportDocument, (responseData: Response) => {
|
@@ -404,11 +392,9 @@ export default defineComponent({
|
404 | 392 | overlaysEnabled: true,
|
405 | 393 | documentRotation: 0,
|
406 | 394 | documentZoom: 100,
|
407 |
| - scrollbarXPos: 0.5, |
408 |
| - scrollbarXSize: 0.5, |
409 |
| - scrollbarYPos: 0.5, |
410 |
| - scrollbarYSize: 0.5, |
411 |
| - bounds: { topX: 0, topY: 0, bottomX: 1, bottomY: 1 }, |
| 395 | + scrollbarPos: { x: 0.5, y: 0.5 }, |
| 396 | + scrollbarSize: { x: 0.5, y: 0.5 }, |
| 397 | + scrollbarMultiplier: { x: 0, y: 0 }, |
412 | 398 | IncrementDirection,
|
413 | 399 | MenuDirection,
|
414 | 400 | SeparatorDirection,
|
|
0 commit comments