Compare commits

...

2 commits

Author SHA1 Message Date
ari melody 4e9acb6502
only mouse1 clicks should cause posts to open 2024-07-01 07:58:48 +01:00
ari melody fe540d791b
whoops! more logging 2024-07-01 07:55:44 +01:00
3 changed files with 19 additions and 7 deletions

View file

@ -32,9 +32,15 @@
let mouse_pos = { top: 0, left: 0 }; let mouse_pos = { top: 0, left: 0 };
function gotoPost() { function gotoPost(event) {
if (focused) return; if (focused) return;
if (event && event.key && event.key !== "Enter") return; if (event) {
if (event.type == "mouseup" && (
event.button !== 0 ||
event.shiftKey ||
event.ctrlKey)) return;
if (event.key && event.key !== "Enter") return;
}
goto(`/post/${post.id}`); goto(`/post/${post.id}`);
} }
@ -62,7 +68,7 @@
aria-label={aria_label} aria-label={aria_label}
bind:this={el} bind:this={el}
on:mousedown={e => {mouse_pos.left = e.pageX; mouse_pos.top = e.pageY}} on:mousedown={e => {mouse_pos.left = e.pageX; mouse_pos.top = e.pageY}}
on:mouseup={e => {if (e.pageX == mouse_pos.left && e.pageY == mouse_pos.top) gotoPost()}} on:mouseup={e => {if (e.pageX == mouse_pos.left && e.pageY == mouse_pos.top) gotoPost(e)}}
on:keydown={gotoPost}> on:keydown={gotoPost}>
<PostHeader post={post} /> <PostHeader post={post} />
<Body post={post} /> <Body post={post} />

View file

@ -16,8 +16,15 @@
let mouse_pos = { top: 0, left: 0 }; let mouse_pos = { top: 0, left: 0 };
function gotoPost() { function gotoPost(event) {
if (event && event.key && event.key !== "Enter") return; if (event) {
if (event.type == "mouseup" && (
event.button !== 0 ||
event.shiftKey ||
event.ctrlKey)) return;
if (event.key && event.key !== "Enter") return;
}
goto(`/post/${post.id}`); goto(`/post/${post.id}`);
} }
</script> </script>
@ -32,7 +39,7 @@
class="post-reply" class="post-reply"
aria-label={aria_label} aria-label={aria_label}
on:mousedown={e => {mouse_pos.left = e.pageX; mouse_pos.top = e.pageY}} on:mousedown={e => {mouse_pos.left = e.pageX; mouse_pos.top = e.pageY}}
on:mouseup={e => {if (e.pageX == mouse_pos.left && e.pageY == mouse_pos.top) gotoPost()}} on:mouseup={e => {if (e.pageX == mouse_pos.left && e.pageY == mouse_pos.top) gotoPost(e)}}
on:keydown={gotoPost}> on:keydown={gotoPost}>
<div class="line"></div> <div class="line"></div>

View file

@ -42,7 +42,6 @@
); );
} }
console.log(post);
return post; return post;
})(); })();
</script> </script>