slightly better
This commit is contained in:
34
src/stores/mappingMode.ts
Normal file
34
src/stores/mappingMode.ts
Normal file
@ -0,0 +1,34 @@
|
||||
import { atom } from 'nanostores'
|
||||
|
||||
export interface MappingModeState {
|
||||
isActive: boolean
|
||||
activeLFO: number | null
|
||||
}
|
||||
|
||||
export const mappingMode = atom<MappingModeState>({
|
||||
isActive: false,
|
||||
activeLFO: null
|
||||
})
|
||||
|
||||
export function enterMappingMode(lfoIndex: number): void {
|
||||
mappingMode.set({
|
||||
isActive: true,
|
||||
activeLFO: lfoIndex
|
||||
})
|
||||
}
|
||||
|
||||
export function exitMappingMode(): void {
|
||||
mappingMode.set({
|
||||
isActive: false,
|
||||
activeLFO: null
|
||||
})
|
||||
}
|
||||
|
||||
export function toggleMappingMode(lfoIndex: number): void {
|
||||
const current = mappingMode.get()
|
||||
if (current.isActive && current.activeLFO === lfoIndex) {
|
||||
exitMappingMode()
|
||||
} else {
|
||||
enterMappingMode(lfoIndex)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user