Scroll to other posts only when they aren't the top post
This commit is contained in:
parent
caf4a3846e
commit
5daec27ad7
|
@ -1,12 +1,11 @@
|
||||||
import React, { Component } from 'react';
|
import React, { Component } from 'react';
|
||||||
import { withStyles, CircularProgress, Typography, Paper, Button, Chip, Avatar, Slide} from '@material-ui/core';
|
import { withStyles, CircularProgress, Typography, Paper} from '@material-ui/core';
|
||||||
import {styles} from './PageLayout.styles';
|
import {styles} from './PageLayout.styles';
|
||||||
import Post from '../components/Post';
|
import Post from '../components/Post';
|
||||||
import { Status } from '../types/Status';
|
import { Status } from '../types/Status';
|
||||||
import { Context } from '../types/Context';
|
import { Context } from '../types/Context';
|
||||||
import Mastodon from 'megalodon';
|
import Mastodon from 'megalodon';
|
||||||
import {withSnackbar} from 'notistack';
|
import {withSnackbar} from 'notistack';
|
||||||
import ArrowUpwardIcon from '@material-ui/icons/ArrowUpward';
|
|
||||||
|
|
||||||
interface IConversationPageState {
|
interface IConversationPageState {
|
||||||
posts?: [Status];
|
posts?: [Status];
|
||||||
|
@ -82,7 +81,7 @@ class Conversation extends Component<any, IConversationPageState> {
|
||||||
|
|
||||||
componentDidUpdate() {
|
componentDidUpdate() {
|
||||||
const where: HTMLElement | null = document.getElementById(`post_${this.state.conversationId}`);
|
const where: HTMLElement | null = document.getElementById(`post_${this.state.conversationId}`);
|
||||||
if (where) {
|
if (where && this.state.posts && this.state.posts[0].id !== this.state.conversationId) {
|
||||||
window.scrollTo(0, where.getBoundingClientRect().top);
|
window.scrollTo(0, where.getBoundingClientRect().top);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue