Fix scroll preservation for customized container scrollbars.
This commit is contained in:
parent
969030a026
commit
aff81c8c92
1 changed files with 7 additions and 2 deletions
9
init.lua
9
init.lua
|
|
@ -752,6 +752,7 @@ local fs_scrollbar = {
|
||||||
return e
|
return e
|
||||||
end,
|
end,
|
||||||
onchange = function(e, fn)
|
onchange = function(e, fn)
|
||||||
|
e._has_onchange = true
|
||||||
ctx._events.on_scrollbar_event[e.__id] = fn
|
ctx._events.on_scrollbar_event[e.__id] = fn
|
||||||
return e
|
return e
|
||||||
end,
|
end,
|
||||||
|
|
@ -805,9 +806,11 @@ local fs_scroll_container = {
|
||||||
end
|
end
|
||||||
out[#out +1] = "scroll_container_end[]"
|
out[#out +1] = "scroll_container_end[]"
|
||||||
|
|
||||||
if not e._scrollbar then
|
|
||||||
local v = e.__fs._ctx.fields[e.__id]
|
local v = e.__fs._ctx.fields[e.__id]
|
||||||
|
if not e._scrollbar then
|
||||||
out[#out +1] = string.format("scrollbar[-800,-800;0,0;%s;%s;%s]", get(e, "orientation"), e.__id, v and v:sub(5) or "")
|
out[#out +1] = string.format("scrollbar[-800,-800;0,0;%s;%s;%s]", get(e, "orientation"), e.__id, v and v:sub(5) or "")
|
||||||
|
elseif not e._scrollbar._has_onchange and v then
|
||||||
|
e._scrollbar.value = v:sub(5)
|
||||||
end
|
end
|
||||||
|
|
||||||
return table.concat(out)
|
return table.concat(out)
|
||||||
|
|
@ -843,7 +846,8 @@ local fs_scroll_container = {
|
||||||
e._scrollbar:onchange(fn)
|
e._scrollbar:onchange(fn)
|
||||||
return e
|
return e
|
||||||
end
|
end
|
||||||
e._scrollbar = fs_scrollbar(-800, -800, 0, 0, e._orientation, e.__id):onchange(fn)
|
e._scrollbar = fs_scrollbar(-800, -800, 0, 0, e._orientation):onchange(fn)
|
||||||
|
e._scrollbar.__id = e.__id
|
||||||
return e
|
return e
|
||||||
end,
|
end,
|
||||||
-- A non-transient name is required in order to preserve scroll position upon a rebuild.
|
-- A non-transient name is required in order to preserve scroll position upon a rebuild.
|
||||||
|
|
@ -1479,6 +1483,7 @@ imfs = {
|
||||||
local container = {__parent = ctx, _events = setmetatable({}, {__index = ctx._events, __newindex = ctx._events}), __fs = ctx.__fs or ctx}
|
local container = {__parent = ctx, _events = setmetatable({}, {__index = ctx._events, __newindex = ctx._events}), __fs = ctx.__fs or ctx}
|
||||||
table.insert(ctx, container)
|
table.insert(ctx, container)
|
||||||
ctx = container
|
ctx = container
|
||||||
|
return container
|
||||||
end,
|
end,
|
||||||
container_end = function()
|
container_end = function()
|
||||||
ctx = ctx.__parent
|
ctx = ctx.__parent
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue