mirror of
https://github.com/Stremio/stremio-web.git
synced 2026-03-11 21:27:05 +00:00
change the board threshhold to be items count instead of px
This commit is contained in:
parent
dd71f9b0ac
commit
a33d9db6dc
2 changed files with 9 additions and 9 deletions
|
|
@ -1,18 +1,18 @@
|
|||
// Copyright (C) 2017-2022 Smart code 203358507
|
||||
|
||||
const isChildVisible = (container, element, threshold) => {
|
||||
const isChildVisible = (container, element) => {
|
||||
const elementTop = element.offsetTop;
|
||||
const elementBottom = element.offsetTop + element.clientHeight;
|
||||
const containerTop = container.scrollTop - threshold;
|
||||
const containerBottom = container.scrollTop + container.clientHeight + threshold;
|
||||
const containerTop = container.scrollTop;
|
||||
const containerBottom = container.scrollTop + container.clientHeight;
|
||||
return (elementTop >= containerTop && elementBottom <= containerBottom) ||
|
||||
(elementTop < containerTop && containerTop < elementBottom) ||
|
||||
(elementTop < containerBottom && containerBottom < elementBottom);
|
||||
};
|
||||
|
||||
const getVisibleChildrenRange = (container, threshold) => {
|
||||
const getVisibleChildrenRange = (container) => {
|
||||
return Array.from(container.children).reduce((result, child, index) => {
|
||||
if (isChildVisible(container, child, threshold)) {
|
||||
if (isChildVisible(container, child)) {
|
||||
if (result === null) {
|
||||
result = {
|
||||
start: index,
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ const useBoard = require('./useBoard');
|
|||
const useContinueWatchingPreview = require('./useContinueWatchingPreview');
|
||||
const styles = require('./styles');
|
||||
|
||||
const THRESHOLD = 300;
|
||||
const THRESHOLD = 5;
|
||||
|
||||
const Board = () => {
|
||||
const profile = useProfile();
|
||||
|
|
@ -18,13 +18,13 @@ const Board = () => {
|
|||
const boardCatalogsOffset = continueWatchingPreview.libraryItems.length > 0 ? 1 : 0;
|
||||
const scrollContainerRef = React.useRef();
|
||||
const onVisibleRangeChange = React.useCallback(() => {
|
||||
const range = getVisibleChildrenRange(scrollContainerRef.current, THRESHOLD);
|
||||
const range = getVisibleChildrenRange(scrollContainerRef.current);
|
||||
if (range === null) {
|
||||
return;
|
||||
}
|
||||
|
||||
const start = Math.max(0, range.start - boardCatalogsOffset);
|
||||
const end = range.end - boardCatalogsOffset;
|
||||
const start = Math.max(0, range.start - boardCatalogsOffset - THRESHOLD);
|
||||
const end = range.end - boardCatalogsOffset + THRESHOLD;
|
||||
if (end < start) {
|
||||
return;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue