mirror of
https://github.com/invoke-ai/InvokeAI
synced 2024-08-30 20:32:17 +00:00
ui: map aspect ratios instead of manually creating the array
This commit is contained in:
parent
8e4d288f02
commit
b13a06f650
@ -15,6 +15,8 @@ const aspectRatios = [
|
||||
{ name: '1:1', value: 1 / 1 },
|
||||
];
|
||||
|
||||
export const mappedAspectRatios = aspectRatios.map((ar) => ar.value);
|
||||
|
||||
export default function ParamAspectRatio() {
|
||||
const aspectRatio = useAppSelector(
|
||||
(state: RootState) => state.generation.aspectRatio
|
||||
|
@ -5,6 +5,7 @@ import { configChanged } from 'features/system/store/configSlice';
|
||||
import { clamp } from 'lodash-es';
|
||||
import { ImageDTO } from 'services/api/types';
|
||||
|
||||
import { mappedAspectRatios } from '../components/Parameters/Core/ParamAspectRatio';
|
||||
import { clipSkipMap } from '../types/constants';
|
||||
import {
|
||||
CfgScaleParam,
|
||||
@ -152,7 +153,7 @@ export const generationSlice = createSlice({
|
||||
},
|
||||
toggleSize: (state) => {
|
||||
const [width, height] = [state.width, state.height];
|
||||
if (![null, 2 / 3, 16 / 9, 1 / 1].includes(height / width)) {
|
||||
if (!mappedAspectRatios.includes(height / width)) {
|
||||
state.aspectRatio = null;
|
||||
}
|
||||
state.width = height;
|
||||
@ -280,7 +281,7 @@ export const generationSlice = createSlice({
|
||||
setShouldLockAspectRatio: (state, action: PayloadAction<boolean>) => {
|
||||
if (
|
||||
action.payload === false &&
|
||||
![null, 2 / 3, 16 / 9, 1 / 1].includes(state.aspectRatio)
|
||||
!mappedAspectRatios.includes(state.aspectRatio)
|
||||
) {
|
||||
state.aspectRatio = null;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user