Viewer的github地址:https://github.com/fengyuanchen/viewer  下载该插件(在文件夹dist里面)

具有参考价值的几个网站:http://www.dowebok.com/demo/192/index3.html      http://www.szbelle.com/article/2890.html      http://www.jq22.com/jquery-info6536

Viewer的使用,参考:http://www.dowebok.com/demo/192/  ,有简单介绍在原生js和jquery中使用,以及回调函数和自定义函数的使用。

  • 静态加载图片 查看: 需要引入jqueryJS、viewer的js css 文件,就可使用强大的Viewer

    <div class="meetingCons" id="chatConDivs" style="overflow:auto;">
             <div id="show">
            <span>2222</span>
            <img data-original="./a.png" src="./a.png" >
            </div>
        <div id="show">
            <span>2222</span>
            <img data-original="./b.png" src="./b.png" >
        </div>
        <div id="show">
            <span>2222</span>
            <img data-original="./applySpeak.png" src="./applySpeak.png" >
        </div>
            <p class="message_time con">2017/8/17 下午2:25:38</p>
            <div class="me con">
                <h5 class="name">我@所有人</h5>
                <div id="show"><div>
                <p style="margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; text-indent:0px">
                    <img id="897990180693082112_1502951138405" data-original="./min.png" src="./sss.png">
                </p>
            </div>
        </div>

    JS引用viewer插件

    $('.meetingCons').viewer('data-original');//一定需要个容器包含所有的img标签,通过url:data-original将所有的img的图片缓存
  • 类似于QQ、微信聊天中会有发送图片,并不是静态加载的图片,这时候需要调用Viewer的方法,需要在js运行时先加载所有的图片,然后在发送图片后或者接收图片后在执行update方法

 

$('.meetingCons').viewer("data-original");//viewer加载所有的聊天图片
$('.meetingCons').viewer("update");//viewer更新所有的图片

 

一些配置:

名称类型默认值说明
inline 布尔值 false 启用 inline 模式
button 布尔值 true 显示右上角关闭按钮(jQuery 版本无效)
navbar 布尔值/整型 true 显示缩略图导航
title 布尔值/整型 true 显示当前图片的标题(现实 alt 属性及图片尺寸)
toolbar 布尔值/整型 true 显示工具栏
tooltip 布尔值 true 显示缩放百分比
movable 布尔值 true 图片是否可移动
zoomable 布尔值 true 图片是否可缩放
rotatable 布尔值 true 图片是否可旋转
scalable 布尔值 true 图片是否可翻转
transition 布尔值 true 使用 CSS3 过度
fullscreen 布尔值 true 播放时是否全屏
keyboard 布尔值 true 是否支持键盘
interval 整型 5000 播放间隔,单位为毫秒
zoomRatio 浮点型 0.1 鼠标滚动时的缩放比例
minZoomRatio 浮点型 0.01 最小缩放比例
maxZoomRatio 数字 100 最大缩放比例
zIndex 数字 2015 设置图片查看器 modal 模式时的 z-index
zIndexInline 数字 0 设置图片查看器 inline 模式时的 z-index
url 字符串/函数 src 设置大图片的 url
build 函数 null 回调函数,具体查看演示
built 函数 null 回调函数,具体查看演示
show 函数 null 回调函数,具体查看演示
shown 函数 null 回调函数,具体查看演示
hide 函数 null 回调函数,具体查看演示
hidden 函数 null 回调函数,具体查看演示
view 函数 null 回调函数,具体查看演示
viewed 函数 null 回调函数,具体查看演示

 

 

posted on 2017-08-17 17:51  qinbb  阅读(995)  评论(0编辑  收藏  举报