Skip to content
107 changes: 59 additions & 48 deletions src/components/Navbar/QuickButton/QuickButton.vue
Original file line number Diff line number Diff line change
Expand Up @@ -70,25 +70,17 @@
<i style="color: #ddd" class="fas fa-expand-arrows-alt"></i>
</button>
</div>
<div class="zoom-slider">
<button class="zoom-slider-decrement" @click="decrement">-</button>
<input
id="customRange1"
type="range"
class="custom-range"
min="0"
max="45"
step="1"
/>
<span id="slider_value"></span>
<button class="zoom-slider-increment" @click="increment">+</button>
<!-- Zoom controls: +/- buttons -->
<div class="zoom-controls">
<button class="zoom-button-decrement" @click="decrement" title="Zoom Out">−</button>
<button class="zoom-button-increment" @click="increment" title="Zoom In">+</button>
</div>
</div>
<div id="exitView"></div>
</template>

<script lang="ts" setup>
import { saveOnline, saveOffline, deleteSelectedItem, createSaveAsImgPrompt, zoomToFit, undoit, redoit, view, decrement, increment } from './QuickButton';
import { saveOnline, saveOffline, deleteSelectedItem, createSaveAsImgPrompt, zoomToFit, undoit, redoit, view, increment, decrement } from './QuickButton'

function dragover(): void {
const quickBtn: HTMLElement | null = document.querySelector('.quick-btn')
Expand Down Expand Up @@ -203,58 +195,77 @@ function dragover(): void {
color: white
}

.zoom-slider {
/* Zoom controls with slider (1-100% display) */
.zoom-controls {
display: flex;
gap: 8px;
align-items: center;
}

.zoom-button-decrement,
.zoom-button-increment {
background: transparent;
color: white;
border: none;
cursor: pointer;
font-size: 20px;
padding-top: 0.2rem;
font-weight: bold;
padding: 0 6px;
line-height: 1;
min-width: 24px;
}

.zoom-slider-decrement {
position: relative;
padding-right: 4px;
bottom: 0.3rem;
}
.zoom-slider-increment {
position: relative;
padding-left: 4px;
bottom: 0.3rem;
.zoom-button-decrement:hover,
.zoom-button-increment:hover {
opacity: 0.7;
}

.custom-range {
width: 80px !important;
}
.custom-range::-moz-range-track {
height: 1px;
.zoom-slider {
width: 100px;
height: 5px;
-webkit-appearance: none;
appearance: none;
background: rgba(255, 255, 255, 0.2);
border-radius: 3px;
outline: none;
cursor: pointer;
}

.custom-range::-moz-range-thumb {
width: 10px;
height: 10px;
background-color: white;
border: 0;
.zoom-slider::-webkit-slider-thumb {
-webkit-appearance: none;
appearance: none;
width: 14px;
height: 14px;
background: white;
border-radius: 50%;
cursor: pointer;
transition: background 0.15s ease-in-out;
}
.custom-range:focus::-moz-range-thumb {
box-shadow: 0 0 0 1px #fff, 0 0 0 0.2rem rgba(75, 86, 99, 0.25);

.zoom-slider::-webkit-slider-thumb:hover {
background: #ddd;
}

input[type='range'] {
-webkit-appearance: none;
.zoom-slider::-moz-range-thumb {
width: 14px;
height: 14px;
background: white;
border: none;
border-radius: 50%;
cursor: pointer;
transition: background 0.15s ease-in-out;
}

input[type='range']::-webkit-slider-runnable-track {
height: 1px;
.zoom-slider::-moz-range-thumb:hover {
background: #ddd;
}

input[type='range']::-webkit-slider-thumb {
-webkit-appearance: none;
width: 10px;
height: 10px;
background-color: white;
border: 0;
border-radius: 50%;
cursor: pointer;
.zoom-label {
color: white;
font-size: 12px;
font-weight: 500;
min-width: 40px;
text-align: right;
}

@media (max-width: 991px) {
Expand Down
95 changes: 76 additions & 19 deletions src/components/Navbar/QuickButton/QuickButtonMobile.vue
Original file line number Diff line number Diff line change
Expand Up @@ -80,19 +80,11 @@
<Hamburger2 v-if="simulatorMobileStore.showMobileView" :navbar-data="navbarData" />
</nav>
</div>
<!-- Zoom controls: +/- buttons -->
<div class="slider-container">
<div class="zoom-slider">
<button class="zoom-slider-decrement" @click="decrement">-</button>
<input
id="customRange1"
type="range"
class="custom-range"
min="0"
max="45"
step="1"
/>
<span id="slider_value"></span>
<button class="zoom-slider-increment" @click="increment">+</button>
<div class="zoom-controls">
<button class="zoom-button-decrement" @click="decrement" title="Zoom Out">−</button>
<button class="zoom-button-increment" @click="increment" title="Zoom In">+</button>
</div>
</div>
</div>
Expand All @@ -101,9 +93,9 @@

<script lang="ts" setup>
import Hamburger2 from '../Hamburger/Hamburger2.vue'
import navbarData from '#/assets/constants/Navbar/NAVBAR_DATA.json'
import { useSimulatorMobileStore } from '#/store/simulatorMobileStore'
import { saveOnline, saveOffline, deleteSelectedItem, createSaveAsImgPrompt, zoomToFit, undoit, redoit, view, decrement, increment } from './QuickButton';
import navbarData from '../../../assets/constants/Navbar/NAVBAR_DATA.json'
import { useSimulatorMobileStore } from '../../../store/simulatorMobileStore'
import { saveOnline, saveOffline, deleteSelectedItem, createSaveAsImgPrompt, zoomToFit, undoit, redoit, view, increment, decrement } from './QuickButton'

const simulatorMobileStore = useSimulatorMobileStore()
</script>
Expand Down Expand Up @@ -154,14 +146,79 @@ const simulatorMobileStore = useSimulatorMobileStore()
color: white;
}

.zoom-slider {
/* Zoom controls with slider (1-100% display) */
.zoom-controls {
display: flex;
gap: 1rem;
width: 90%;
justify-content: center;
align-items: center;
padding: 0.5rem 0;
}

.zoom-button-decrement,
.zoom-button-increment {
background: transparent;
color: white;
border: none;
cursor: pointer;
font-size: 24px;
font-weight: bold;
padding: 0 8px;
line-height: 1;
min-width: 32px;
}

.zoom-button-decrement:hover,
.zoom-button-increment:hover {
opacity: 0.7;
}

.zoom-slider {
width: 120px;
height: 6px;
-webkit-appearance: none;
appearance: none;
background: rgba(255, 255, 255, 0.2);
border-radius: 3px;
outline: none;
cursor: pointer;
}

.zoom-slider::-webkit-slider-thumb {
-webkit-appearance: none;
appearance: none;
width: 16px;
height: 16px;
background: white;
border-radius: 50%;
cursor: pointer;
transition: background 0.15s ease-in-out;
}

.custom-range {
width: 90% !important;
.zoom-slider::-webkit-slider-thumb:hover {
background: #ddd;
}

.zoom-slider::-moz-range-thumb {
width: 16px;
height: 16px;
background: white;
border: none;
border-radius: 50%;
cursor: pointer;
transition: background 0.15s ease-in-out;
}

.zoom-slider::-moz-range-thumb:hover {
background: #ddd;
}

.zoom-label {
color: white;
font-size: 14px;
font-weight: 500;
min-width: 45px;
text-align: right;
}

@media (max-width: 768px) {
Expand Down
11 changes: 7 additions & 4 deletions src/simulator/src/embedListeners.js
Original file line number Diff line number Diff line change
Expand Up @@ -174,16 +174,19 @@ export default function startListeners() {
updateSimulationSet(true);
updatePositionSet(true);

// zoom in (+)
// Zoom is now on Cmd/Ctrl +/- (primary zoom method)
if (e.key == 'Meta' || e.key == 'Control') {
simulationArea.controlDown = true;
}
if (simulationArea.controlDown && (e.keyCode == 187 || e.KeyCode == 171)) {
// Zoom in: Cmd/Ctrl + '+' or Cmd/Ctrl + '='
// (On US keyboards, '+' is Shift+'=', so we accept both to handle with/without Shift)
if (simulationArea.controlDown && (e.keyCode == 187 || e.keyCode == 171 || e.key == '+' || e.key == '=')) {
e.preventDefault();
ZoomIn();
}
// zoom out (-)
if (simulationArea.controlDown && (e.keyCode == 189 || e.Keycode == 173)) {
// Zoom out: Cmd/Ctrl + '-'
// (Only '-', not '_', since '_' requires Shift and could cause confusion)
if (simulationArea.controlDown && (e.keyCode == 189 || e.keyCode == 173 || e.key == '-')) {
e.preventDefault();
ZoomOut();
}
Expand Down
2 changes: 1 addition & 1 deletion src/simulator/src/engine.js
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@ export function updateSelectionsAndPane(scope = globalScope) {
simulationArea.lastSelected === scope.root &&
simulationArea.mouseDown
) {
// pane canvas to give an idea of grid moving
// Original behavior: pan canvas when dragging on empty space (not selecting objects)
if (!objectSelection) {
globalScope.ox =
simulationArea.mouseRawX -
Expand Down
Loading
Loading