Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/lib/ToolBox.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
let customSnappingDialogOpened: boolean = false
let customSnappingDialogValue: number = 0
$: customSnappingDialogValue = snapTo
let snappingSelect: HTMLSelectElement
export let snappingSelect: HTMLSelectElement
</script>

<div class="toolbox-container">
Expand Down
15 changes: 15 additions & 0 deletions src/lib/control/ControlHandler.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
MODES,
MODE_SHORTCUTS,
MODE_SHORTCUTS_NUMERAL,
SnapTo,
} from '$lib/editing/modes'
import { KEYBOARD_SHORTCUTS } from '$lib/control/keyboard'

Expand All @@ -13,6 +14,7 @@
// Stores
import { inside } from '$lib/position'
import { preferences } from '$lib/preferences'
import { resizingLastWidth } from '$lib/editing/resizing'

type KeyboardEvents = {
[K in KeyboardAction]: void
Expand All @@ -26,12 +28,25 @@

export let zoom: number
export let scrollTick: number
export let snappingSelect: HTMLSelectElement
export let snapTo: SnapTo

function mousewheel(event: WheelEvent) {
if (!$inside) return
event.preventDefault()
if (event.ctrlKey) {
zoom -= (event.deltaY > 0 ? 0.1 : -0.1) * (event.shiftKey ? 10 : 1)
} else if (event.altKey && event.shiftKey) {
snappingSelect.selectedIndex = Math.min(
Math.max(snappingSelect.selectedIndex + (event.deltaY > 0 ? 1 : -1), 0),
snappingSelect.options.length - 2
)
snapTo = parseInt(snappingSelect.options[snappingSelect.selectedIndex].value)
} else if (event.altKey) {
$resizingLastWidth = Math.min(
Math.max($resizingLastWidth + (event.deltaY > 0 ? -1 : 1), 1),
12
)
} else {
scrollTick -=
(event.deltaY *
Expand Down
4 changes: 4 additions & 0 deletions src/routes/edit.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -354,6 +354,7 @@

let currentMode: Mode = 'select'
let snapTo: SnapTo = SNAPTO_DEFAULT
let snappingSelect: HTMLSelectElement

$: dbg('scrollTick', scrollTick)

Expand Down Expand Up @@ -1277,6 +1278,7 @@
bind:currentMode
bind:snapTo
bind:openMainMenu
bind:snappingSelect
on:about={() => {
aboutDialogOpened = true
}}
Expand Down Expand Up @@ -1687,6 +1689,8 @@
<ControlHandler
bind:zoom
bind:scrollTick
bind:snapTo
bind:snappingSelect
on:undo={onundo}
on:redo={onredo}
on:export={onexport}
Expand Down