首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >FramerJS -具有滚动组件的水平滚动条

FramerJS -具有滚动组件的水平滚动条
EN

Stack Overflow用户
提问于 2017-09-26 12:24:35
回答 1查看 368关注 0票数 0

我已经创建了一个可滚动的区域,并试图在图像下面添加一个滚动条(链接图像中的蓝色滚动条)。

当前可滚动区域的代码。

代码语言:javascript
复制
scroll = new ScrollComponent
opacity: 1.00
shadowBlur: 0
scroll.size = screen
Info.parent = scroll.content 
scroll.scrollVertical = false

滚动

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2017-09-28 14:19:34

我认为您正在尝试创建一个滚动条,该滚动条将显示用户滚动的距离,对吗?下面是一些代码,如何做到这一点:

代码语言:javascript
复制
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

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/46426505

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档