kopia lustrzana https://gitlab.com/soapbox-pub/soapbox
Scroll to the relevant post in the thread, fixes #257
rodzic
30ebdf30ff
commit
b007fc4ac1
|
@ -142,6 +142,16 @@ class Status extends ImmutablePureComponent {
|
||||||
componentDidMount() {
|
componentDidMount() {
|
||||||
this.props.dispatch(fetchStatus(this.props.params.statusId));
|
this.props.dispatch(fetchStatus(this.props.params.statusId));
|
||||||
attachFullscreenListener(this.onFullScreenChange);
|
attachFullscreenListener(this.onFullScreenChange);
|
||||||
|
const { ancestorsIds } = this.props;
|
||||||
|
|
||||||
|
if (ancestorsIds && ancestorsIds.size > 0) {
|
||||||
|
const element = this.node.querySelectorAll('.focusable')[ancestorsIds.size - 1];
|
||||||
|
|
||||||
|
window.requestAnimationFrame(() => {
|
||||||
|
element.scrollIntoView(true);
|
||||||
|
});
|
||||||
|
this._scrolledIntoView = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
handleToggleMediaVisibility = () => {
|
handleToggleMediaVisibility = () => {
|
||||||
|
@ -391,8 +401,7 @@ class Status extends ImmutablePureComponent {
|
||||||
}
|
}
|
||||||
|
|
||||||
componentDidUpdate(prevProps, prevState) {
|
componentDidUpdate(prevProps, prevState) {
|
||||||
const { params, status } = this.props;
|
const { params, status, ancestorsIds } = this.props;
|
||||||
const { ancestorsIds } = prevProps;
|
|
||||||
|
|
||||||
if (params.statusId !== prevProps.params.statusId && params.statusId) {
|
if (params.statusId !== prevProps.params.statusId && params.statusId) {
|
||||||
this._scrolledIntoView = false;
|
this._scrolledIntoView = false;
|
||||||
|
@ -403,11 +412,7 @@ class Status extends ImmutablePureComponent {
|
||||||
this.setState({ showMedia: defaultMediaVisibility(status), loadedStatusId: status.get('id') });
|
this.setState({ showMedia: defaultMediaVisibility(status), loadedStatusId: status.get('id') });
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this._scrolledIntoView) {
|
if (ancestorsIds && ancestorsIds.size > 0) {
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (prevProps.status && ancestorsIds && ancestorsIds.size > 0) {
|
|
||||||
const element = this.node.querySelectorAll('.focusable')[ancestorsIds.size - 1];
|
const element = this.node.querySelectorAll('.focusable')[ancestorsIds.size - 1];
|
||||||
|
|
||||||
window.requestAnimationFrame(() => {
|
window.requestAnimationFrame(() => {
|
||||||
|
|
Ładowanie…
Reference in New Issue