mirror of
https://github.com/NoCrypt/migu.git
synced 2026-01-11 20:10:22 +00:00
feat: secondary RSS click action
long press or right click will go to anime episodes list
This commit is contained in:
parent
aabf0ffea0
commit
5ef28324df
3 changed files with 35 additions and 2 deletions
|
|
@ -41,6 +41,7 @@ Includes all original Miru features, plus:
|
|||
- Moved toast close button to the bottom for better reachability on Android
|
||||
- Disabled smooth scrolling by default due to poor performance on my device
|
||||
- Gesture lock on Android to prevent misclick
|
||||
- Right click or long press on RSS Section will open the anime episode list
|
||||
|
||||
## **Building and Development**
|
||||
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@
|
|||
import { liveAnimeEpisodeProgress } from '@/modules/animeprogress.js'
|
||||
import { anilistClient } from '@/modules/anilist.js'
|
||||
import { SUPPORTS } from '@/modules/support.js';
|
||||
import { longpress } from '@/modules/longpress.js'
|
||||
|
||||
export let data
|
||||
|
||||
|
|
@ -18,8 +19,8 @@
|
|||
|
||||
const view = getContext('view')
|
||||
function viewMedia () {
|
||||
if (SUPPORTS.isAndroid) document.querySelector('.content-wrapper').requestFullscreen()
|
||||
if (data.onclick) {
|
||||
if (SUPPORTS.isAndroid) document.querySelector('.content-wrapper').requestFullscreen()
|
||||
data.onclick()
|
||||
return
|
||||
}
|
||||
|
|
@ -29,6 +30,10 @@
|
|||
preview = state
|
||||
}
|
||||
|
||||
function viewEpisodes(){
|
||||
$view = media
|
||||
}
|
||||
|
||||
let thisElement;
|
||||
|
||||
onMount(() => {
|
||||
|
|
@ -43,7 +48,7 @@
|
|||
const progress = liveAnimeEpisodeProgress(media?.id, data?.episode)
|
||||
</script>
|
||||
|
||||
<div class='d-flex p-20 pb-10 position-relative episode-card' bind:this={thisElement}>
|
||||
<div class='d-flex p-20 pb-10 position-relative episode-card' bind:this={thisElement} on:contextmenu={viewEpisodes} use:longpress={viewEpisodes} role="none">
|
||||
{#if preview}
|
||||
{#if !SUPPORTS.isAndroid}
|
||||
<EpisodePreviewCard {data} />
|
||||
|
|
|
|||
27
common/modules/longpress.js
Normal file
27
common/modules/longpress.js
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
export function longpress(node, cb = () => {}) {
|
||||
const threshold = 500
|
||||
const handle_mousedown = () => {
|
||||
let start = Date.now();
|
||||
|
||||
const timeout = setTimeout(() => {
|
||||
cb();
|
||||
}, threshold);
|
||||
|
||||
const cancel = () => {
|
||||
clearTimeout(timeout);
|
||||
node.removeEventListener('mousemove', cancel);
|
||||
node.removeEventListener('mouseup', cancel);
|
||||
};
|
||||
|
||||
node.addEventListener('mousemove', cancel);
|
||||
node.addEventListener('mouseup', cancel);
|
||||
}
|
||||
|
||||
node.addEventListener('mousedown', handle_mousedown);
|
||||
|
||||
return {
|
||||
destroy() {
|
||||
node.removeEventListener('mousedown', handle_mousedown);
|
||||
}
|
||||
};
|
||||
}
|
||||
Loading…
Reference in a new issue