Fixed: Artists posters flickering when width changes repeatedly

(cherry picked from commit 53cf5308931069638c23925596a3fd8aaccc5d98)

Closes #64448
pull/4470/head
Mark McDowall 4 months ago committed by Bogdan
parent 1b19e44562
commit 9aae065c5d

@ -39,8 +39,17 @@ export interface CustomFilter {
filers: PropertyFilter[]; filers: PropertyFilter[];
} }
export interface AppSectionState {
dimensions: {
isSmallScreen: boolean;
width: number;
height: number;
};
}
interface AppState { interface AppState {
albums: AlbumAppState; albums: AlbumAppState;
app: AppSectionState;
artist: ArtistAppState; artist: ArtistAppState;
artistIndex: ArtistIndexAppState; artistIndex: ArtistIndexAppState;
history: HistoryAppState; history: HistoryAppState;

@ -213,13 +213,18 @@ export default function ArtistIndexPosters(props: ArtistIndexPostersProps) {
if (current) { if (current) {
const width = current.clientWidth; const width = current.clientWidth;
const padding = bodyPadding - 5; const padding = bodyPadding - 5;
const finalWidth = width - padding * 2;
if (Math.abs(size.width - finalWidth) < 20 || size.width === finalWidth) {
return;
}
setSize({ setSize({
width: width - padding * 2, width: finalWidth,
height: window.innerHeight, height: window.innerHeight,
}); });
} }
}, [isSmallScreen, scrollerRef, bounds]); }, [isSmallScreen, size, scrollerRef, bounds]);
useEffect(() => { useEffect(() => {
const currentScrollListener = isSmallScreen ? window : scrollerRef.current; const currentScrollListener = isSmallScreen ? window : scrollerRef.current;

@ -1,8 +1,9 @@
import { createSelector } from 'reselect'; import { createSelector } from 'reselect';
import AppState from 'App/State/AppState';
function createDimensionsSelector() { function createDimensionsSelector() {
return createSelector( return createSelector(
(state) => state.app.dimensions, (state: AppState) => state.app.dimensions,
(dimensions) => { (dimensions) => {
return dimensions; return dimensions;
} }
Loading…
Cancel
Save