[Glitch] Prevent timeline from moving when cursor is hovering over it
Port 9188537f5f
to glitch-soc
This commit is contained in:
parent
3fc6e7dabb
commit
1c75c7901f
1 changed files with 11 additions and 2 deletions
|
@ -35,6 +35,7 @@ export default class ScrollableList extends PureComponent {
|
|||
|
||||
state = {
|
||||
fullscreen: null,
|
||||
mouseOver: false,
|
||||
};
|
||||
|
||||
intersectionObserverWrapper = new IntersectionObserverWrapper();
|
||||
|
@ -85,7 +86,7 @@ export default class ScrollableList extends PureComponent {
|
|||
const someItemInserted = React.Children.count(prevProps.children) > 0 &&
|
||||
React.Children.count(prevProps.children) < React.Children.count(this.props.children) &&
|
||||
this.getFirstChildKey(prevProps) !== this.getFirstChildKey(this.props);
|
||||
if (someItemInserted && this.node.scrollTop > 0) {
|
||||
if (someItemInserted && this.node.scrollTop > 0 || this.state.mouseOver) {
|
||||
return this.node.scrollHeight - this.node.scrollTop;
|
||||
} else {
|
||||
return null;
|
||||
|
@ -147,6 +148,14 @@ export default class ScrollableList extends PureComponent {
|
|||
this.props.onScrollToBottom();
|
||||
}
|
||||
|
||||
handleMouseEnter = () => {
|
||||
this.setState({ mouseOver: true });
|
||||
}
|
||||
|
||||
handleMouseLeave = () => {
|
||||
this.setState({ mouseOver: false });
|
||||
}
|
||||
|
||||
render () {
|
||||
const { children, scrollKey, trackScroll, shouldUpdateScroll, isLoading, hasMore, prepend, emptyMessage } = this.props;
|
||||
const { fullscreen } = this.state;
|
||||
|
@ -157,7 +166,7 @@ export default class ScrollableList extends PureComponent {
|
|||
|
||||
if (isLoading || childrenCount > 0 || !emptyMessage) {
|
||||
scrollableArea = (
|
||||
<div className={classNames('scrollable', { fullscreen })} ref={this.setRef}>
|
||||
<div className={classNames('scrollable', { fullscreen })} ref={this.setRef} onMouseEnter={this.handleMouseEnter} onMouseLeave={this.handleMouseLeave}>
|
||||
<div role='feed' className='item-list'>
|
||||
{prepend}
|
||||
|
||||
|
|
Loading…
Reference in a new issue