Fix tempo slider dragging and width
This commit is contained in:
1 parent
8ef90b5898
commit
ec2792736d
2 files changed
+72
-23
No files matched your search
@@ -1,5 +1,6 @@
|
||||
import { memo } from 'react';
|
||||
import { IonButton, IonIcon, IonPopover, IonRange } from '@ionic/react';
|
||||
import type { CSSProperties } from 'react';
|
||||
import { IonButton, IonIcon, IonPopover } from '@ionic/react';
|
||||
import { chevronDown } from 'ionicons/icons';
|
||||
import { MAX_TEMPO_BPM, MIN_TEMPO_BPM } from '../domain/sequencer';
|
||||
import { usePopoverDisclosure } from '../hooks/usePopoverDisclosure';
|
||||
@@ -11,6 +12,7 @@ interface TempoControlProps {
|
||||
|
||||
export const TempoControl = memo(function TempoControl({ tempoBpm, onTempoChange }: TempoControlProps) {
|
||||
const popover = usePopoverDisclosure();
|
||||
const tempoProgress = ((tempoBpm - MIN_TEMPO_BPM) / (MAX_TEMPO_BPM - MIN_TEMPO_BPM)) * 100;
|
||||
|
||||
return (
|
||||
<>
|
||||
@@ -40,16 +42,16 @@ export const TempoControl = memo(function TempoControl({ tempoBpm, onTempoChange
|
||||
<div className="tempo-popover-content">
|
||||
<output className="tempo-value" aria-live="polite">{tempoBpm} BPM</output>
|
||||
<div className="tempo-range-track">
|
||||
<IonRange
|
||||
<input
|
||||
className="tempo-range"
|
||||
type="range"
|
||||
aria-label="Tempo in beats per minute"
|
||||
min={MIN_TEMPO_BPM}
|
||||
max={MAX_TEMPO_BPM}
|
||||
step={1}
|
||||
value={tempoBpm}
|
||||
onIonInput={(event) => {
|
||||
if (typeof event.detail.value === 'number') onTempoChange(event.detail.value);
|
||||
}}
|
||||
style={{ '--tempo-progress': `${tempoProgress}%` } as CSSProperties}
|
||||
onChange={(event) => onTempoChange(event.currentTarget.valueAsNumber)}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in new issue
Block a user