do not render dummy for comment once it gets into viewport

This commit is contained in:
Vyrtsev Mikhail
2020-01-19 12:51:28 -06:00
committed by Umputun
parent 8c37fac06e
commit 029f50c52c
+7 -1
View File
@@ -52,6 +52,7 @@ export type Props = {
} & Partial<typeof boundActions>;
export interface State {
renderDummy: boolean;
isCopied: boolean;
editDeadline: Date | null;
voteErrorMessage: string | null;
@@ -79,6 +80,7 @@ export class Comment extends Component<Props, State> {
super(props);
this.state = {
renderDummy: typeof props.inView === 'boolean' ? !props.inView : false,
isCopied: false,
editDeadline: null,
voteErrorMessage: null,
@@ -115,6 +117,10 @@ export class Comment extends Component<Props, State> {
cachedScore: props.data.score,
};
if (props.inView) {
newState.renderDummy = false;
}
// set comment edit timer
if (props.user && props.user.id === props.data.user.id) {
const editDuration = StaticStore.config.edit_duration;
@@ -540,7 +546,7 @@ export class Comment extends Component<Props, State> {
);
}
if (!props.editMode && this.props.inView === false) {
if (this.state.renderDummy && !props.editMode) {
const [width, height] = this.base
? [(this.base as Element).scrollWidth, (this.base as Element).scrollHeight]
: [100, 100];