Ver código fonte

Change window resize handler to switch to/from mobile layout as soon as needed (#11656)

master^2
ThibG 4 anos atrás
committed by Eugen Rochko
pai
commit
bd4099d976
1 arquivos alterados com 14 adições e 4 exclusões
  1. +14
    -4
      app/javascript/mastodon/features/ui/index.js

+ 14
- 4
app/javascript/mastodon/features/ui/index.js Ver arquivo

@@ -141,14 +141,24 @@ class SwitchingColumnsArea extends React.PureComponent {
return location.state !== previewMediaState && location.state !== previewVideoState;
}

handleResize = debounce(() => {
handleLayoutChange = debounce(() => {
// The cached heights are no longer accurate, invalidate
this.props.onLayoutChange();

this.setState({ mobile: isMobile(window.innerWidth) });
}, 500, {
trailing: true,
});
})

handleResize = () => {
const mobile = isMobile(window.innerWidth);

if (mobile !== this.state.mobile) {
this.handleLayoutChange.cancel();
this.props.onLayoutChange();
this.setState({ mobile });
} else {
this.handleLayoutChange();
}
}

setRef = c => {
this.node = c.getWrappedInstance();


Carregando…
Cancelar
Salvar