javascript - 在 Framer.js 中打印滚动位置

标签 javascript coffeescript prototype framerjs

我正在 Framer.js 中进行原型(prototype)设计。我有一个滚动组件和滚动内容,我正在尝试打印内容的当前x 或scrollX 位置。因此,如果我向右滚动 500px,代码将打印 500

Bg = new BackgroundLayer
backgroundColor: 'FFF'

scroll = new ScrollComponent 
    width: 750
    height: 1334
    scrollVertical: false

layerA = new Layer 
        width: 750 * 5
        height: 1334 
        superLayer: scroll.content

layerA.style.background = "-webkit-linear-gradient(45deg, #2AF 0%, #F00 100%)"

# get current x value of scroll content
print layerA.scrollX

成帧器演示:http://share.framerjs.com/70pi1l6is76t/

Codepen 演示:http://codepen.io/matter/pen/78fc798001529418123b84470ea8c625?editors=0010

提前谢谢您,

最佳答案

您可以通过添加事件监听器来打印当前的scrollX值:

scroll.onScroll ->
    print scroll.scrollX

有关事件的更多信息:http://framerjs.com/docs/#events.events

更新了 Framer 演示:http://share.framerjs.com/jvmsrtmm7i5g/

关于javascript - 在 Framer.js 中打印滚动位置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35856561/

相关文章:

javascript - 让模型听嵌套模型和集合的最佳模式?

c - 返回字符串数组的 C 函数原型(prototype)

javascript - 防止浏览器自动填写表单域

Javascript:for..in 循环运行次数超过预期

javascript - 用户可以输入正则表达式的输入表单

node.js - Jasmine Node 找不到规范模块

javascript - 为什么这个广泛使用的脚本会杀死我的处理器

javascript - 无需安装编译器即可编译嵌入式 CoffeeScript?

javascript - 通过在 "namespace"中添加函数来扩展对象原型(prototype)

JavaScript 关联数组访问返回 "literal"数组原型(prototype)代码