fix: context menu viewport sınır kontrolü - alta/sağa taşma düzeltildi
All checks were successful
Build MIPS Binary / build (push) Successful in 5m14s
All checks were successful
Build MIPS Binary / build (push) Successful in 5m14s
This commit is contained in:
@@ -63,24 +63,35 @@ pub fn TorrentContextMenu(
|
|||||||
|
|
||||||
<Show when=move || open.get()>
|
<Show when=move || open.get()>
|
||||||
{
|
{
|
||||||
let (x, y) = position.get();
|
let (x, y) = position.get();
|
||||||
view! {
|
// Menü yaklaşık boyutları
|
||||||
<div
|
let menu_width = 200;
|
||||||
class="fixed inset-0 z-[99]"
|
let menu_height = 220;
|
||||||
on:click=move |e: MouseEvent| {
|
let window = web_sys::window().unwrap();
|
||||||
e.stop_propagation();
|
let vw = window.inner_width().unwrap().as_f64().unwrap() as i32;
|
||||||
open.set(false);
|
let vh = window.inner_height().unwrap().as_f64().unwrap() as i32;
|
||||||
}
|
// Sağa taşarsa sola aç, alta taşarsa yukarı aç
|
||||||
on:contextmenu=move |e: MouseEvent| {
|
let final_x = if x + menu_width > vw { x - menu_width } else { x };
|
||||||
e.prevent_default();
|
let final_y = if y + menu_height > vh { y - menu_height } else { y };
|
||||||
e.stop_propagation();
|
let final_x = final_x.max(0);
|
||||||
open.set(false);
|
let final_y = final_y.max(0);
|
||||||
}
|
view! {
|
||||||
/>
|
<div
|
||||||
<div
|
class="fixed inset-0 z-[99]"
|
||||||
class="fixed z-[100] min-w-[12rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-md animate-in fade-in-0 zoom-in-95"
|
on:click=move |e: MouseEvent| {
|
||||||
style=format!("left: {}px; top: {}px;", x, y)
|
e.stop_propagation();
|
||||||
on:click=move |e: MouseEvent| e.stop_propagation()
|
open.set(false);
|
||||||
|
}
|
||||||
|
on:contextmenu=move |e: MouseEvent| {
|
||||||
|
e.prevent_default();
|
||||||
|
e.stop_propagation();
|
||||||
|
open.set(false);
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
<div
|
||||||
|
class="fixed z-[100] min-w-[12rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-md animate-in fade-in-0 zoom-in-95"
|
||||||
|
style=format!("left: {}px; top: {}px;", final_x, final_y)
|
||||||
|
on:click=move |e: MouseEvent| e.stop_propagation()
|
||||||
>
|
>
|
||||||
// Start
|
// Start
|
||||||
<div
|
<div
|
||||||
|
|||||||
Reference in New Issue
Block a user