JQUERY插件-响应式Photoviewer.js图片查看器jQuery插件

Photoviewer.js是一个基于窗口的照片查看器jQuery插件。插件可以生成一组图像的预览,并将图像放置在可以自由拖动,缩放的窗口中,并且内部的图像可以缩放、旋转。

使用方法

在页面中引入photoviewer.css、jquery和photoviewer.js文件。

<link href="dist/photoviewer.css" rel="stylesheet">
<script src="assets/js/jquery.min.js"></script>
<script src="assets/js/photoviewer.js"></script>

初始化插件

使用photoviewer非常简单,通过下面的方法来初始化即可。

// build images array
var items = [
{
src: 'path/to/image1.jpg', // path to image
caption: 'Image Caption 1' // If you skip it, there will display the original image name(image1)
},
{
src: 'path/to/image2.jpg',
caption: 'Image Caption 2'
}
];

// define options (if needed)
var options = {
// optionName: 'option value'
// for example:
index: 0 // this option means you will start at first image
};

// Initialize the plugin
var viewer = new PhotoViewer(items, options);

最后通过一个按钮来触发打开photoviewer即可。
使用超链接创建

HTML DOM结构如下:

<a data-gallery="manual" href="big-1.jpg">
<img src="small-1.jpg">
</a>
<a data-gallery="manual" href="big-2.jpg">
<img src="small-2.jpg">
</a>
<a data-gallery="manual" href="big-3.jpg">
<img src="small-3.jpg">
</a>

初始化插件:

$('[data-gallery=manual]').click(function (e) {

e.preventDefault();

var items = [],
// get index of element clicked
options = {
index: $(this).index()
};

// looping to create images array
$('[data-gallery=manual]').each(function () {
let src = $(this).attr('href');
items.push({
src: src
});
});

new PhotoViewer(items, options);

});

作为jQuery插件来使用

HTML DOM结构如下:

<a data-gallery="manual" href="big-1.jpg">
<img src="small-1.jpg">
</a>
<a data-gallery="manual" href="big-2.jpg">
<img src="small-2.jpg">
</a>
<a data-gallery="manual" href="big-3.jpg">
<img src="small-3.jpg">
</a>

或者:

<img data-gallery="jquery" data-src="big-1.jpg" src="small-1.jpg">
<img data-gallery="jquery" data-src="big-2.jpg" src="small-2.jpg">
<img data-gallery="jquery" data-src="big-3.jpg" src="small-3.jpg">

初始化插件:

$('[data-gallery=jquery]').photoviewer(options);

创建消息通知

初始化插件:

new jBox('Notice', {
content: 'Hurray! A notice!',
color: 'blue'
});

GitHub地址:https://github.com/nzbin/photoviewer

在线预览 网盘下载

查看如下隐藏内容里的“提取码”:

关注公众号关注公众号
关注公众号,发送消息“查看密码”,输入系统回复的“查看密码”,点击“确定”按钮,即可看到“提取码”。

郑重声明:

1 本资源来源于互联网,资源的版权归资源原作者所持有,受《中华人民共和国著作权法》等相关法律保护。

2 由于无法和原作者取得联系,所以上传的部分资源无法先通过原作者的同意就分享给大家了,如本资源侵犯了您(原作者)的权益,请联系我们(微信号 xiaohaimei1989),我们会立马删除您的资源,并向您表达诚挚的歉意!

3 本站是一个公益型网站,分享资源的目的在于传播知识,分享知识,收取一点点打赏的辛苦费是用于网站的日常运营开支,并非用于商业用途。

4 本站资源只提供学习和参考研究使用,使用过后请在第一时间内删除。本站不承担资源被单位或个人商用带来的法律责任。

发表评论