js交集监测插件scrollama.js

所属分类:UI-滚动

 25056  326  查看评论 (4)
分享到微信朋友圈
X
js交集监测插件scrollama.js ie兼容9

如何使用

基本

您可以使用此库来简单地触发步骤, 类似于点之类的内容。如果您需要对交互式控件进行更多的控制, 或者不希望遵循粘性的 scrollytelling 模式, 这将非常有用。

您可以使用所需的任何 id/类命名约定。HTML 结构应该如下:

<!--you don't need the "data-step" attr, but can be useful for storing instructions for JS -->
<div class='step' data-step='a'></div>
<div class='step' data-step='b'></div>
<div class='step' data-step='c'></div>
// 实例化 scrollama
const scroller = Scrollama()

// 设置实例, 传递回调函数
scroller.setup({
  step: '.step', // 必填
  offset: 0.5,   // 偏移optional, default = 0.5
  debug: false,  // 调试optional, default = false
})
.onStepEnter(handleStepEnter)
.onStepExit(handleStepExit)

粘性图形

要实现粘滞图形 scrollytelling 模式, 您需要以下三元素 (container, graphic, step)。结构应该如下:

<!-- container = ".scroll" -->
<div class='scroll'>
  <!-- graphic = ".scroll__graphic" -->
  <div class='scroll__graphic'>
    <!--graphic / chart code here-->
  </div>
  <div class='scroll__text'>
    <!-- steps = ".step" -->
    <div class='step' data-step='a'></div>
    <div class='step' data-step='b'></div>
    <div class='step' data-step='c'></div>
  </div>
</div>
// 实例化scrollama
const scroller = Scrollama()
// 设置实例,传递回调函数
scroller.setup({
  step: '.scroll__text .step', // required
  container: '.scroll',        // required (for sticky)
  graphic: '.scroll__graphic', // required (for sticky)
  offset: 0.5,                 // optional, default = 0.5
  debug: false,                // optional, default = false
})
.onStepEnter(handleStepEnter)
.onStepExit(handleStepExit)
.onContainerEnter(handleContainerEnter)
.onContainerExit(handleContainerExit)

API

scrollama.setup([options])

  • step (string):将触发更改的步骤元素的选择器。必填

  • container (string): 包含滚动的所有内容的元素的选择器。选

  • graphic (string): 将变为固定的图形元素的选择器。选

  • offset (number, 0 - 1): 从视窗的顶部到触发步骤有多远。(默认值: 0.5)

  • progress (boolean): 是否触发增量步骤进度更新。(默认值: false)

  • debug (boolean): 是否显示可视化调试工具。(默认值: false)

相关插件-滚动

jQuery瀑布流插件

jQuery瀑布流,结合animate.css、wow.js滚动展示效果,可扩展性强。
  滚动
 29287  313

js交集监测插件scrollama.js

Scrollama是一个轻量级JavaScript库, 用于检测页面滚动时监听元素是否重叠。
  滚动
 25057  326

jQuery锚点带动跳转页面代码

jQuery锚点带动跳转页面代码
  滚动
 42418  369

jQuery美化滚动条插件mCustomScrollbar

mCustomScrollbar 是个基于 jQuery UI 的自定义滚动条插件,它可以让你灵活的通过 CSS 定义网页的滚动条,并且垂直和水平两个方向的滚动条都可以定义
  滚动
 32562  335

讨论这个项目(4)回答他人问题或分享插件使用方法奖励jQ币 评论用户自律公约

    像是青柠味° 0
    2020/8/28 14:34:01
    内嵌到app里不起作用吗 回复
    豌豆 0
    2019/5/10 10:35:44
    iexn 0
    2017/11/23 9:09:31

    有明显的bug,没测出来吗

        西瓜0
        2017/11/23 23:15:33

        嵌套在ifrome中有向上不触发的bug, 实际应用没有的,你可以下载到本地查看都是正常的。

    回复
😃
  • 😀
  • 😉
  • 😥
  • 😵
  • 😫
  • 😘
  • 😡
  • 👍
  • 🌹
  • 👏
  • 🍺
  • 🍉
  • 🌙
  • 💖
  • 💔
😃
  • 😀
  • 😉
  • 😥
  • 😵
  • 😫
  • 😘
  • 😡
  • 👍
  • 🌹
  • 👏
  • 🍺
  • 🍉
  • 🌙
  • 💖
  • 💔
取消回复