state = {
fullscreen: null,
+ cachedMediaWidth: 250, // Default media/card width using default Mastodon theme
};
intersectionObserverWrapper = new IntersectionObserverWrapper();
this.handleScroll();
}
+ getScrollPosition = () => {
+ if (this.node && (this.node.scrollTop > 0 || this.mouseMovedRecently)) {
+ return { height: this.node.scrollHeight, top: this.node.scrollTop };
+ } else {
+ return null;
+ }
+ }
+
+ updateScrollBottom = (snapshot) => {
+ const newScrollTop = this.node.scrollHeight - snapshot;
+
+ this.setScrollTop(newScrollTop);
+ }
+
getSnapshotBeforeUpdate (prevProps) {
const someItemInserted = React.Children.count(prevProps.children) > 0 &&
React.Children.count(prevProps.children) < React.Children.count(this.props.children) &&
}
}
+ cacheMediaWidth = (width) => {
+ if (width && this.state.cachedMediaWidth !== width) {
+ this.setState({ cachedMediaWidth: width });
+ }
+ }
+
componentWillUnmount () {
this.clearMouseIdleTimer();
this.detachScrollListener();
intersectionObserverWrapper={this.intersectionObserverWrapper}
saveHeightKey={trackScroll ? `${this.context.router.route.location.key}:${scrollKey}` : null}
>
- {child}
+ {React.cloneElement(child, {
+ getScrollPosition: this.getScrollPosition,
+ updateScrollBottom: this.updateScrollBottom,
+ cachedMediaWidth: this.state.cachedMediaWidth,
+ cacheMediaWidth: this.cacheMediaWidth,
+ })}
</IntersectionObserverArticleContainer>
))}