
Security News
GitHub Actions Checkout Now Blocks Risky pull_request_target Checkouts
GitHub Actions checkout now blocks risky pull_request_target checkouts by default to help prevent pwn request supply chain attacks.
jroll-viewer
Advanced tools
一款基于JRoll开发的图集查看器插件
必须 JRoll v2.4.x 以上
若document.body高度超出一屏,即当document.body.scrollTop不为0时会影响本插件的滚动效果。
请将document.body的css样式设为overflow:hidden;height:100%,超出内容使用JRoll进行滑动
Tips:html的height为100%时,body的高度才能占满全屏
支持标签、CommonJS、AMD、CMD方式引入
<!-- 先引入JRoll再引入JRollViewer -->
<script src="jroll.js"></script>
<script src="jroll-viewer.js"></script>
define(['jroll', 'jroll-viewer'], function (JRoll, JRollViewer) {
var viewer = new JRollViewer('#viewer'{
JRoll: JRoll //不能确定引入顺序时可以参数形式将JRoll传给JRollViewer
})
})
<!-- 基本用法 -->
<div id="viewer">
<img src="http://www.cdn.cn/1.png" jroll-viewer-image>
<img src="../images/2.jpg" jroll-viewer-image>
<img src="../images/3.gif">
</div>
<script>
var viewer = new JRollViewer('#viewer')
</script>
div#viewer容器里存放img图片,图片必须带jroll-viewer-image标记new JRollViewer('#viewer')将div#viewer创建为JRollViewer实例容器jroll-viewer-image标记的图片即可打开图片查看器new JRollViewer(el [, options])
| 键名 | 默认值 | 说明 |
|---|---|---|
| data | undefined | 小图dataset的属性作为大图读取的图片路径,若不指定该选项,默认读取小图src |
| zoomMax | 图片原始值 | 图片最大缩放倍数,以window.innerWidth为1 |
| afterSwitch | undefined | 图片切换后执行的回调函数,function (i) {...} i为切换后图片的索引值,索引从0开始 |
| JRoll | window.JRoll | 用于异步引入JRoll,不能确保window.JRoll比window.JRollViewer先加载完成时使用 |
例:
<div id="viewer">
<img src="http://www.cdn.cn/1.png" data-big="http://www.cdn.cn/b1.png" jroll-viewer-image>
</div>
<script>
var viewer = new JRollViewer('#viewer', {
data: 'big',
zoomMax: 3,
JRoll: window.JRoll
})
</script>
// 打开第一张图片
viewer.show(0)
// or 打开src为`../images/2.jpg`的图片
viewer.show('../images/2.jpg')
// or 打开指定 img dom 的图片
viewer.show(document.getElementById('viewer').children[0])
一个参数,打开选中的图片
收起图片查看器
viewer.hide()
手动切换图片,可利用该方法做图片自动轮播
viewer.switch(1, 200)
viewer.switch(index[, duration])
afterSwitch方法目前默认点击图集查看器时会自动退出,如果需要点击时不退出,而是显示自己的头部导航等内容时,可以自行改写点击事件
在自己的退出按钮点击执行hide方法即可退出图集查看器
document.getElementById('jroll_viewer').onclick = function () {
// 你的代码
}
FAQs
一款基于JRoll开发的图集查看器插件
The npm package jroll-viewer receives a total of 4 weekly downloads. As such, jroll-viewer popularity was classified as not popular.
We found that jroll-viewer demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
GitHub Actions checkout now blocks risky pull_request_target checkouts by default to help prevent pwn request supply chain attacks.

Product
Socket now supports Custom Roles and Repository Access Permissions so organizations can control who can access specific repositories and actions.

Product
Socket MCP now lets AI assistants review org alerts, investigate threats using the Socket threat feed, and inspect package files in addition to dependency scoring.