Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

scroll area #2

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 41 additions & 0 deletions src/2.reactive-ui/scrollarea.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# ScrollArea Demo

using Stipple, Stipple.ReactiveTools
using StippleUI

@appname ScrollDemo

@app begin
@in position = 300
@in scroll = false

@onbutton scroll begin
run(__model__, "this.\$refs.scrollArea.setScrollPosition($position, 500)")
position = rand(0:1000)
end
end

ui() = [
heading("Scroll Area Demo" * h4("with server-side and client-side update"))

row(cell(class = "st-module", [

row(class = "row q-gutter-md q-mb-md", [
btn(R"`Scroll to ${position}px`", color = "primary", @click(raw"() => this.$refs.scrollArea.setScrollPosition(position)"))
btn(R"`Animate to ${position}px`", color = "primary", @click(:scroll))
])

scrollarea(ref = "scrollArea", style = "height: 150px; max-width: 300px;",
ol(
li(@recur("n in 1000"), key! = "n", "Lorem ipsum dolor sit amet, consectetur adipisicing elit.")
)
)
]))
]

route("/") do
model = @init
page(model, ui()) |> html
end

up(open_browser = true)