[FEAT] Clean code
This commit is contained in:
@@ -32,7 +32,6 @@ export function useZoom(options: ZoomOptions) {
|
||||
if (currentIndex < options.allowedValues.length - 1) {
|
||||
zoom.value = options.allowedValues[currentIndex + 1];
|
||||
} else if (currentIndex === -1) {
|
||||
// Find the nearest higher value
|
||||
const higher = options.allowedValues.find(v => v > zoom.value);
|
||||
if (higher !== undefined) {
|
||||
zoom.value = higher;
|
||||
@@ -49,7 +48,6 @@ export function useZoom(options: ZoomOptions) {
|
||||
if (currentIndex > 0) {
|
||||
zoom.value = options.allowedValues[currentIndex - 1];
|
||||
} else if (currentIndex === -1) {
|
||||
// Find the nearest lower value
|
||||
const lower = [...options.allowedValues].reverse().find(v => v < zoom.value);
|
||||
if (lower !== undefined) {
|
||||
zoom.value = lower;
|
||||
@@ -66,7 +64,6 @@ export function useZoom(options: ZoomOptions) {
|
||||
if (isStepOptions(options)) {
|
||||
zoom.value = Math.max(options.min, Math.min(options.max, value));
|
||||
} else {
|
||||
// Snap to nearest allowed value
|
||||
const nearest = options.allowedValues.reduce((prev, curr) => (Math.abs(curr - value) < Math.abs(prev - value) ? curr : prev));
|
||||
zoom.value = nearest;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user