我已经创建了一个可滚动的区域,并试图在图像下面添加一个滚动条(链接图像中的蓝色滚动条)。
当前可滚动区域的代码。
scroll = new ScrollComponent
opacity: 1.00
shadowBlur: 0
scroll.size = screen
Info.parent = scroll.content
scroll.scrollVertical = false发布于 2017-09-28 14:19:34
我认为您正在尝试创建一个滚动条,该滚动条将显示用户滚动的距离,对吗?下面是一些代码,如何做到这一点:
scrollbar.parent = scroll
# First make the width of the scrollbar relative to the size of the content.
scrollbar.width = (scroll.width / scroll.content.width) * scroll.width
# When the scroll is moved
scroll.onMove ->
# Calculate the width that we should scroll over
width = scroll.content.width - scroll.width
# Calculate the percentage that has currently been scrolled
percentage = scroll.scrollX / width
# Calculate how much space there for the scrollbar to move in
freeSpace = scroll.width - scrollbar.width
# Set the position of the scrollbar relative to the free space and the percentage scrolled
scrollbar.x = freeSpace * percentage下面是一个完整的示例:https://framer.cloud/QtcLD
https://stackoverflow.com/questions/46426505
复制相似问题