Fix widget resizing handles, edge anchoring, scroll sync, and axis limits
Launcher / test (pull_request) Successful in 1m19s
Launcher / apk (pull_request) Skipped

This commit is contained in:
Sprite committed 2026-11-23 05:29:33 +00:00
1 parent 216c80252d
commit bb978fd6de
13 files changed
+538 -76

No files matched your search

+1 -1
View File
@@ -155,7 +155,7 @@ extern "js" fn fetch_text(url : String, f : (Bool, String) -> Unit) -> Unit =
///|
/// Measure the viewport and the home grid (into `window.__m`); false without a grid.
extern "js" fn measure() -> Bool =
#|() => { const s = document.querySelector(".slots"), h = document.querySelector(".home"); if (!s || !h) return false; const r = s.getBoundingClientRect(); window.__m = [innerWidth, innerHeight, r.left, r.top, r.width, parseFloat(getComputedStyle(h).paddingBottom) || 0]; return true; }
#|() => { const s = document.querySelector(".slots"), h = document.querySelector(".home"); if (!s || !h) return false; const r = s.getBoundingClientRect(); window.__m = [innerWidth, innerHeight, r.left, r.top, r.width, parseFloat(getComputedStyle(h).paddingBottom) || 0, window.scrollY || 0]; return true; }
///|
/// Measurement i: viewport width, height, grid left, top, width, the home's bottom padding.
+25 -8
View File
@@ -214,11 +214,10 @@ fn render() -> Unit {
}
///|
fn after_render() -> Unit {
fn sync_measure() -> Unit {
let st = state.val
fill_icons()
if measure() {
let key = "\{measured(0)},\{measured(1)},\{measured(2)},\{measured(3)},\{measured(4)},\{measured(5)}"
let key = "\{measured(0)},\{measured(1)},\{measured(2)},\{measured(3)},\{measured(4)},\{measured(5)},\{measured(6)}"
if key != st.measured {
st.measured = key
dispatch(
@@ -229,10 +228,18 @@ fn after_render() -> Unit {
grid_top=measured(3),
grid_w=measured(4),
bottom_pad=measured(5),
scroll_y=measured(6),
),
)
}
}
}
///|
fn after_render() -> Unit {
let st = state.val
fill_icons()
sync_measure()
if is_android() {
place()
cover()
@@ -381,6 +388,7 @@ fn is_dragging() -> Bool {
fn wire_events() -> Unit {
listen("document", "pointerdown", true, fn(e) {
if ev_primary(e) {
sync_measure()
feed(Down(x=ev_x(e), y=ev_y(e), chain=parse_chain(ev_chain(e))))
}
})
@@ -439,9 +447,12 @@ fn wire_events() -> Unit {
})
listen("window", "resize", true, fn(_) { schedule_render() })
listen("window", "scroll", true, fn(_) {
if is_android() {
request_frame(place)
}
request_frame(fn() {
sync_measure()
if is_android() {
place()
}
})
})
}
@@ -459,8 +470,14 @@ fn expose_api() -> Unit {
expose0("home", fn() { dispatch(GoHome) })
expose0("back", fn() { dispatch(Back) })
expose1("widgetAdded", fn(id) { dispatch(WidgetAdded(id)) })
expose1("widgetMenu", fn(id) { dispatch(WidgetMenu(id)) })
expose1("widgetGrab", fn(id) { dispatch(WidgetGrab(id)) })
expose1("widgetMenu", fn(id) {
sync_measure()
dispatch(WidgetMenu(id))
})
expose1("widgetGrab", fn(id) {
sync_measure()
dispatch(WidgetGrab(id))
})
expose_dd("widgetDrag", fn(x, y) { dispatch(NativeDrag(x, y)) })
expose_b("widgetDrop", fn(moved) { dispatch(NativeDrop(moved)) })
expose0("place", fn() {
+23 -11
View File
@@ -157,25 +157,37 @@ body { margin: 0; min-height: 100vh; color: #fff; -webkit-tap-highlight-color: t
up or resized (or while its native view is away, e.g. another widget is being resized). */
.widget-slot[data-wid]:not(.lifted):not(.resizing) { background: none; border-color: transparent; }
/* A widget being resized: handles sit just outside its right and bottom edges, where the
native widget view doesn't cover them; the bottom one sits in the gap below the row. */
/* A widget being resized: generous 36-40px handles straddle the widget border (inset enough
to stay inside the viewport on full-width widgets); WidgetView passes edge touches through. */
.widget-slot { position: relative; }
.widget-slot.resizing { z-index: 2; outline: 2px solid rgb(255 255 255 / .85);
outline-offset: 3px; transition: none; }
.resize-handle { position: absolute; z-index: 2; touch-action: none; cursor: nwse-resize; }
.resize-handle::after { content: ""; position: absolute; border-radius: 999px; background: #fff;
box-shadow: 0 1px 6px rgb(0 0 0 / .45); }
.resize-handle[data-edge="r"] { top: 0; bottom: 0; right: -16px; width: 16px; cursor: ew-resize; }
.resize-handle[data-edge="r"]::after { top: 50%; left: 6px; width: 6px; height: 2.5rem; transform: translateY(-50%); }
.resize-handle[data-edge="b"] { left: 0; right: 0; bottom: -1rem; height: 1rem; cursor: ns-resize; }
.resize-handle[data-edge="b"]::after { left: 50%; top: 5px; width: 2.5rem; height: 6px; transform: translateX(-50%); }
.resize-handle[data-edge="rb"] { right: -16px; bottom: -1rem; width: 2.75rem; height: 1rem; }
.resize-handle[data-edge="rb"]::after { right: 4px; top: 1px; width: 14px; height: 14px; border-radius: 4px; }
box-shadow: 0 1px 6px rgb(0 0 0 / .45);
transition: background-color .1s, box-shadow .1s; }
.resize-handle.active::after, .resize-handle:active::after {
background: #93c5fd;
box-shadow: 0 0 0 4px rgb(147 197 253 / .35), 0 2px 8px rgb(0 0 0 / .55);
}
.resize-handle[data-edge="l"] { top: 12px; bottom: 12px; left: -14px; width: 36px; cursor: ew-resize; }
.resize-handle[data-edge="l"]::after { top: 50%; left: 7px; width: 6px; height: 2.25rem; transform: translateY(-50%); }
.resize-handle[data-edge="r"] { top: 12px; bottom: 12px; right: -14px; width: 36px; cursor: ew-resize; }
.resize-handle[data-edge="r"]::after { top: 50%; right: 7px; width: 6px; height: 2.25rem; transform: translateY(-50%); }
.resize-handle[data-edge="t"] { left: 12px; right: 12px; top: -14px; height: 36px; cursor: ns-resize; }
.resize-handle[data-edge="t"]::after { left: 50%; top: 7px; width: 2.25rem; height: 6px; transform: translateX(-50%); }
.resize-handle[data-edge="b"] { left: 12px; right: 12px; bottom: -14px; height: 36px; cursor: ns-resize; }
.resize-handle[data-edge="b"]::after { left: 50%; bottom: 7px; width: 2.25rem; height: 6px; transform: translateX(-50%); }
.resize-handle[data-edge="rb"] { right: -14px; bottom: -14px; width: 40px; height: 40px; z-index: 3; cursor: nwse-resize; }
.resize-handle[data-edge="rb"]::after { right: 3px; bottom: 3px; width: 16px; height: 16px; border-radius: 5px; }
.resize-bar { position: fixed; left: 50%; bottom: calc(var(--bottom) + 1rem); z-index: 15; transform: translateX(-50%);
display: flex; align-items: center; gap: .5rem; padding: .4rem .4rem .4rem 1rem; border-radius: 999px;
background: rgb(0 0 0 / .8); color: #fff; font-size: .875rem; white-space: nowrap;
display: flex; align-items: center; gap: .5rem; padding: .4rem .4rem .4rem .75rem; border-radius: 999px;
background: rgb(0 0 0 / .82); color: #fff; font-size: .875rem; white-space: nowrap;
animation: ui-fade .15s; }
.resize-bar { max-width: calc(100vw - 1rem); }
.resize-size { flex: none; padding: .15rem .5rem; border-radius: 999px;
background: rgb(255 255 255 / .16); font-size: .75rem; font-weight: 600;
font-variant-numeric: tabular-nums; }
.resize-hint { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.resize-bar .btn { flex: none; }
.resize-bar .btn.ghost { color: #fff; }