mirror of
https://github.com/Stremio/stremio-web.git
synced 2026-04-20 19:02:15 +00:00
Merge pull request #915 from Stremio/fix/discover-metaitem-tap-mobile
Fix(Discover): enable direct navigation to meta item on mobile on first tap
This commit is contained in:
commit
5f53b9b44a
2 changed files with 9 additions and 4 deletions
|
|
@ -24,7 +24,7 @@ const ALLOWED_LINK_REDIRECTS = [
|
|||
routesRegexp.metadetails.regexp
|
||||
];
|
||||
|
||||
const MetaPreview = ({ className, compact, name, logo, background, runtime, releaseInfo, released, description, deepLinks, links, trailerStreams, inLibrary, toggleInLibrary }) => {
|
||||
const MetaPreview = React.forwardRef(({ className, compact, name, logo, background, runtime, releaseInfo, released, description, deepLinks, links, trailerStreams, inLibrary, toggleInLibrary }, ref) => {
|
||||
const { t } = useTranslation();
|
||||
const [shareModalOpen, openShareModal, closeShareModal] = useBinaryState(false);
|
||||
const linksGroups = React.useMemo(() => {
|
||||
|
|
@ -98,7 +98,7 @@ const MetaPreview = ({ className, compact, name, logo, background, runtime, rele
|
|||
<div className={styles['logo-placeholder']}>{name}</div>
|
||||
), [name]);
|
||||
return (
|
||||
<div className={classnames(className, styles['meta-preview-container'], { [styles['compact']]: compact })}>
|
||||
<div className={classnames(className, styles['meta-preview-container'], { [styles['compact']]: compact })} ref={ref}>
|
||||
{
|
||||
typeof background === 'string' && background.length > 0 ?
|
||||
<div className={styles['background-image-layer']}>
|
||||
|
|
@ -261,7 +261,7 @@ const MetaPreview = ({ className, compact, name, logo, background, runtime, rele
|
|||
</div>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
});
|
||||
|
||||
MetaPreview.Placeholder = MetaPreviewPlaceholder;
|
||||
|
||||
|
|
|
|||
|
|
@ -20,7 +20,10 @@ const Discover = ({ urlParams, queryParams }) => {
|
|||
const [inputsModalOpen, openInputsModal, closeInputsModal] = useBinaryState(false);
|
||||
const [addonModalOpen, openAddonModal, closeAddonModal] = useBinaryState(false);
|
||||
const [selectedMetaItemIndex, setSelectedMetaItemIndex] = React.useState(0);
|
||||
|
||||
const metasContainerRef = React.useRef();
|
||||
const metaPreviewRef = React.useRef();
|
||||
|
||||
React.useEffect(() => {
|
||||
if (discover.catalog?.content.type === 'Loading') {
|
||||
metasContainerRef.current.scrollTop = 0;
|
||||
|
|
@ -75,7 +78,8 @@ const Discover = ({ urlParams, queryParams }) => {
|
|||
}
|
||||
}, []);
|
||||
const metaItemOnClick = React.useCallback((event) => {
|
||||
if (event.currentTarget.dataset.index !== selectedMetaItemIndex.toString()) {
|
||||
const visible = window.getComputedStyle(metaPreviewRef.current).display !== 'none';
|
||||
if (event.currentTarget.dataset.index !== selectedMetaItemIndex.toString() && visible) {
|
||||
event.preventDefault();
|
||||
event.currentTarget.focus();
|
||||
}
|
||||
|
|
@ -175,6 +179,7 @@ const Discover = ({ urlParams, queryParams }) => {
|
|||
<MetaPreview
|
||||
className={styles['meta-preview-container']}
|
||||
compact={true}
|
||||
ref={metaPreviewRef}
|
||||
name={selectedMetaItem.name}
|
||||
logo={selectedMetaItem.logo}
|
||||
background={selectedMetaItem.poster}
|
||||
|
|
|
|||
Loading…
Reference in a new issue