|
80 | 80 | <Hamburger2 v-if="simulatorMobileStore.showMobileView" :navbar-data="navbarData" /> |
81 | 81 | </nav> |
82 | 82 | </div> |
83 | | - <!-- Zoom slider: 1-100% mapped to internal zoom scale via setZoomFromSlider API --> |
| 83 | + <!-- Zoom controls: +/- buttons --> |
84 | 84 | <div class="slider-container"> |
85 | 85 | <div class="zoom-controls"> |
86 | | - <button class="zoom-button-decrement" @click="decrementZoom" title="Zoom Out">−</button> |
87 | | - <input |
88 | | - type="range" |
89 | | - v-model.number="displayZoomPercent" |
90 | | - @input="onZoomSliderInput" |
91 | | - min="1" |
92 | | - max="100" |
93 | | - step="1" |
94 | | - class="zoom-slider" |
95 | | - title="Zoom Level" |
96 | | - /> |
97 | | - <button class="zoom-button-increment" @click="incrementZoom" title="Zoom In">+</button> |
98 | | - <span class="zoom-label">{{ displayZoomPercent }}%</span> |
| 86 | + <button class="zoom-button-decrement" @click="decrement" title="Zoom Out">−</button> |
| 87 | + <button class="zoom-button-increment" @click="increment" title="Zoom In">+</button> |
99 | 88 | </div> |
100 | 89 | </div> |
101 | 90 | </div> |
102 | 91 | <div id="exitView"></div> |
103 | 92 | </template> |
104 | 93 |
|
105 | 94 | <script lang="ts" setup> |
106 | | -import { ref, onMounted } from 'vue' |
107 | 95 | import Hamburger2 from '../Hamburger/Hamburger2.vue' |
108 | 96 | import navbarData from '../../../assets/constants/Navbar/NAVBAR_DATA.json' |
109 | 97 | import { useSimulatorMobileStore } from '../../../store/simulatorMobileStore' |
110 | | -import { saveOnline, saveOffline, deleteSelectedItem, createSaveAsImgPrompt, zoomToFit, undoit, redoit, view } from './QuickButton' |
111 | | -// @ts-ignore - simulator functions are not typed |
112 | | -import { setZoomFromSlider, getZoomSliderValue } from '../../../simulator/src/listeners' |
| 98 | +import { saveOnline, saveOffline, deleteSelectedItem, createSaveAsImgPrompt, zoomToFit, undoit, redoit, view, increment, decrement } from './QuickButton' |
113 | 99 |
|
114 | 100 | const simulatorMobileStore = useSimulatorMobileStore() |
115 | | -
|
116 | | -// Display zoom constants (user-facing percentage values) |
117 | | -const DISPLAY_ZOOM_MIN = 1 |
118 | | -const DISPLAY_ZOOM_MAX = 100 |
119 | | -const DISPLAY_ZOOM_DEFAULT = 50 |
120 | | -const DISPLAY_ZOOM_STEP = 5 |
121 | | -
|
122 | | -// Internal zoom constants (simulator scale range) |
123 | | -const INTERNAL_ZOOM_MIN = 0 |
124 | | -const INTERNAL_ZOOM_MAX = 200 |
125 | | -
|
126 | | -// Current zoom level displayed to user (1-100%) |
127 | | -const displayZoomPercent = ref(DISPLAY_ZOOM_DEFAULT) |
128 | | -
|
129 | | -/** |
130 | | - * Clamp zoom percentage to valid display range |
131 | | - */ |
132 | | -const clampZoomPercent = (value: number): number => { |
133 | | - return Math.max(DISPLAY_ZOOM_MIN, Math.min(DISPLAY_ZOOM_MAX, value)) |
134 | | -} |
135 | | -
|
136 | | -/** |
137 | | - * Convert internal zoom value (0-200) to display percentage (1-100%) |
138 | | - */ |
139 | | -const convertInternalToDisplayZoom = (internalValue: number): number => { |
140 | | - return Math.round((internalValue / INTERNAL_ZOOM_MAX) * 100) |
141 | | -} |
142 | | -
|
143 | | -/** |
144 | | - * Convert display percentage (1-100%) to internal zoom value (0-200) |
145 | | - */ |
146 | | -const convertDisplayToInternalZoom = (displayPercent: number): number => { |
147 | | - return (displayPercent / 100) * INTERNAL_ZOOM_MAX |
148 | | -} |
149 | | -
|
150 | | -/** |
151 | | - * Initialize zoom slider with current simulator zoom level |
152 | | - */ |
153 | | -const initializeZoomSlider = () => { |
154 | | - try { |
155 | | - const currentInternalZoom = getZoomSliderValue(INTERNAL_ZOOM_MIN, INTERNAL_ZOOM_MAX) |
156 | | - const currentDisplayZoom = convertInternalToDisplayZoom(currentInternalZoom) |
157 | | - displayZoomPercent.value = clampZoomPercent(currentDisplayZoom) |
158 | | - } catch (error) { |
159 | | - console.warn('Could not initialize zoom slider:', error) |
160 | | - displayZoomPercent.value = DISPLAY_ZOOM_DEFAULT |
161 | | - } |
162 | | -} |
163 | | -
|
164 | | -/** |
165 | | - * Update simulator zoom based on current display percentage |
166 | | - */ |
167 | | -const updateSimulatorZoom = () => { |
168 | | - try { |
169 | | - const internalZoomValue = convertDisplayToInternalZoom(displayZoomPercent.value) |
170 | | - setZoomFromSlider(internalZoomValue, INTERNAL_ZOOM_MIN, INTERNAL_ZOOM_MAX) |
171 | | - } catch (error) { |
172 | | - console.warn('Could not apply zoom:', error) |
173 | | - } |
174 | | -} |
175 | | -
|
176 | | -/** |
177 | | - * Increase zoom level by one step |
178 | | - */ |
179 | | -const incrementZoom = () => { |
180 | | - displayZoomPercent.value = clampZoomPercent(displayZoomPercent.value + DISPLAY_ZOOM_STEP) |
181 | | - updateSimulatorZoom() |
182 | | -} |
183 | | -
|
184 | | -/** |
185 | | - * Decrease zoom level by one step |
186 | | - */ |
187 | | -const decrementZoom = () => { |
188 | | - displayZoomPercent.value = clampZoomPercent(displayZoomPercent.value - DISPLAY_ZOOM_STEP) |
189 | | - updateSimulatorZoom() |
190 | | -} |
191 | | -
|
192 | | -/** |
193 | | - * Handle slider input event - updates zoom in real-time as user drags |
194 | | - */ |
195 | | -const onZoomSliderInput = () => { |
196 | | - updateSimulatorZoom() |
197 | | -} |
198 | | -
|
199 | | -onMounted(initializeZoomSlider) |
200 | 101 | </script> |
201 | 102 |
|
202 | 103 | <style scoped> |
|
0 commit comments