diff --git a/packages/ludic.ui/native.ludic b/packages/ludic.ui/native.ludic index d1fdde34..f4a69575 100644 --- a/packages/ludic.ui/native.ludic +++ b/packages/ludic.ui/native.ludic @@ -85,6 +85,15 @@ export function ui_attr(n: UiNode, key: string) -> Val { } return Value.null() } +# whether an element has the attribute at all: ui_attr's miss is a new null, so a question asked +# every frame asks this first +export function ui_attr_has(n: UiNode, key: string) -> bool { + if n.akeys == null { return false } + for i in 0 .. len(n.akeys) { + if n.akeys[i] == key { return true } + } + return false +} export function ui_attr_text(n: UiNode, key: string) -> string { if n.akeys == null { return "" } for i in 0 .. len(n.akeys) { diff --git a/packages/ludic.ui/scroll_held.ludic b/packages/ludic.ui/scroll_held.ludic index a0599e59..dbd56955 100644 --- a/packages/ludic.ui/scroll_held.ludic +++ b/packages/ludic.ui/scroll_held.ludic @@ -25,7 +25,9 @@ function sc_held(ui_st: mut UiState, n: UiNode, off: float, live: bool) -> float List.pop(pxs) } } - let v = ui_attr(n, "scroll-top") - if Value.kind(v) != 0 { at = ui_px(ui_st, el_numv(ui_st, v)) } + if ui_attr_has(n, "scroll-top") { + let v = ui_attr(n, "scroll-top") + if Value.kind(v) != 0 { at = ui_px(ui_st, el_numv(ui_st, v)) } + } return at }