increase zoom of buttons + refactor
This commit is contained in:
parent
c3f0d640ef
commit
e88a059222
|
|
@ -51,11 +51,13 @@ export function TimelineToolbar({
|
|||
setZoomLevel: ({ zoom }: { zoom: number }) => void;
|
||||
}) {
|
||||
const handleZoom = ({ direction }: { direction: "in" | "out" }) => {
|
||||
const zoomFactor = 1.25;
|
||||
const newZoomLevel =
|
||||
direction === "in"
|
||||
? Math.min(TIMELINE_CONSTANTS.ZOOM_MAX, zoomLevel * zoomFactor)
|
||||
: Math.max(minZoom, zoomLevel / zoomFactor);
|
||||
? Math.min(
|
||||
TIMELINE_CONSTANTS.ZOOM_MAX,
|
||||
zoomLevel * TIMELINE_CONSTANTS.ZOOM_BUTTON_FACTOR,
|
||||
)
|
||||
: Math.max(minZoom, zoomLevel / TIMELINE_CONSTANTS.ZOOM_BUTTON_FACTOR);
|
||||
setZoomLevel({ zoom: newZoomLevel });
|
||||
};
|
||||
|
||||
|
|
@ -297,7 +299,7 @@ function ToolbarRightSection({
|
|||
type="button"
|
||||
onClick={() => onZoom({ direction: "out" })}
|
||||
>
|
||||
<HugeiconsIcon icon={SearchAddIcon} />
|
||||
<HugeiconsIcon icon={SearchMinusIcon} />
|
||||
</Button>
|
||||
<Slider
|
||||
className="w-28"
|
||||
|
|
@ -315,7 +317,7 @@ function ToolbarRightSection({
|
|||
type="button"
|
||||
onClick={() => onZoom({ direction: "in" })}
|
||||
>
|
||||
<HugeiconsIcon icon={SearchMinusIcon} />
|
||||
<HugeiconsIcon icon={SearchAddIcon} />
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -35,12 +35,10 @@ export const TRACK_GAP = 4;
|
|||
export const TIMELINE_CONSTANTS = {
|
||||
PIXELS_PER_SECOND: 50,
|
||||
DEFAULT_ELEMENT_DURATION: 5,
|
||||
PLAYHEAD_LOOKAHEAD_SECONDS: 30, // padding ahead
|
||||
PADDING_TOP_PX: 0,
|
||||
ZOOM_LEVELS: [0.1, 0.25, 0.5, 1, 1.5, 2, 3, 4, 6, 8, 10, 15, 20, 30, 50],
|
||||
ZOOM_MIN: 0.1,
|
||||
ZOOM_MAX: 100,
|
||||
ZOOM_STEP: 0.1,
|
||||
ZOOM_BUTTON_FACTOR: 1.7,
|
||||
} as const;
|
||||
|
||||
export const DEFAULT_TIMELINE_VIEW_STATE: TTimelineViewState = {
|
||||
|
|
|
|||
|
|
@ -53,8 +53,8 @@ export function getZoomPercent({
|
|||
}
|
||||
|
||||
/**
|
||||
* Convert linear slider position (0-1) to exponential zoom level.
|
||||
* At low slider values, zoom changes are small. At high values, changes are large.
|
||||
* convert linear slider position (0-1) to exponential zoom level.
|
||||
* at low slider values, zoom changes are small. at high values, changes are large.
|
||||
*/
|
||||
export function sliderToZoom({
|
||||
sliderPosition,
|
||||
|
|
|
|||
Loading…
Reference in New Issue