mirror of
https://github.com/cheeaun/phanpy.git
synced 2025-03-23 06:09:21 +01:00
Bring back intersection observer for 'show more'
Sometimes the scroll thing doesn't really work
This commit is contained in:
parent
2ced21c9dd
commit
cbb09e1b5d
1 changed files with 16 additions and 7 deletions
|
@ -1,5 +1,6 @@
|
||||||
import { useEffect, useRef, useState } from 'preact/hooks';
|
import { useEffect, useRef, useState } from 'preact/hooks';
|
||||||
import { useHotkeys } from 'react-hotkeys-hook';
|
import { useHotkeys } from 'react-hotkeys-hook';
|
||||||
|
import { InView } from 'react-intersection-observer';
|
||||||
import { useDebouncedCallback } from 'use-debounce';
|
import { useDebouncedCallback } from 'use-debounce';
|
||||||
|
|
||||||
import useInterval from '../utils/useInterval';
|
import useInterval from '../utils/useInterval';
|
||||||
|
@ -376,6 +377,13 @@ function Timeline({
|
||||||
</ul>
|
</ul>
|
||||||
{uiState === 'default' &&
|
{uiState === 'default' &&
|
||||||
(showMore ? (
|
(showMore ? (
|
||||||
|
<InView
|
||||||
|
onChange={(inView) => {
|
||||||
|
if (inView) {
|
||||||
|
loadItems();
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
>
|
||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
class="plain block"
|
class="plain block"
|
||||||
|
@ -384,6 +392,7 @@ function Timeline({
|
||||||
>
|
>
|
||||||
Show more…
|
Show more…
|
||||||
</button>
|
</button>
|
||||||
|
</InView>
|
||||||
) : (
|
) : (
|
||||||
<p class="ui-state insignificant">The end.</p>
|
<p class="ui-state insignificant">The end.</p>
|
||||||
))}
|
))}
|
||||||
|
|
Loading…
Add table
Reference in a new issue