益吾库源码下载jQuery弹出层插件Fancybox

jQuery弹出层插件Fancybox

jQuery弹出层插件Fancybox
2017年08月12日 17:07:44益点益滴源码下载3578

资源介绍

Fancybox是一款优秀的jquery插件,它能够展示丰富的弹出层、弹出框、弹出窗口效果。前面我们有文章介绍了facybox弹出层效果,相比facybox,fancybox显得功能更为齐全,它除了可以加载DIV,图片、图片集、Ajax数据,还能加载SWF影片,iframe页面等等。Fancybox目前最新版本是3.2.1,使用方法跟v2相差无几,只是控制显示样式、效果的参数选项有些变化。

Fancybox的特点:
可以支持图片、html文本、flash动画、iframe以及ajax的支持
可以自定义播放器的CSS样式
可以以组的形式进行播放
如果将鼠标滚动插件(mouse wheel plugin)包含进来的话Fancybox还能支持鼠标滚轮滚动来翻阅图片
Fancybox播放器支持投影,更有立体的感觉
Fancybox使用方法:
1、引入jquery核心库和Fancybox插件库
<script type="text/javascript" src="jquery.min.js"></script>
<script type="text/javascript" src="jquery.fancybox.min.js"></script>
2、添加样式表文件
<link rel="stylesheet" href="jquery.fancybox.min.css" type="text/css" media="screen">
3、在页面上创建链接元素
A、图片元素
<a id="single_image" href="image_big.jpg"><img src="image_small.jpg" kesrc="image_small.jpg" alt=""></a>
B、普通文本
<a id="inline" href="#data" kesrc="#data">This shows content of element who has id="data"</a> 
<div style="display: none;">
    <div id="data">Lorem ipsum dolor sit amet, consectetur adipiscing elit.</div>
</div>
C、Iframe
<a href="http://www.example?iframe">This goes to iframe</a> 
或者
 <a class="iframe" href="http://www.example.com">This goes to iframe</a>
D、Ajax
<a href="http://www.example/data.php">This takes content using ajax</a>
如果你要显示描述信息,可以在链接上加上title,将描述信息放到title中。

使用 JavaScript 初始化

实际测试,按照步骤做完上面三步即可在单击图片时调用 Fancybox v3.x 的灯箱了。不过通过这第四步可以修改灯箱组件的默认选项设置。使用 jQuery 选择器选择带有 data-fancybox 属性的元素并调用 fancybox 方法,来给该元素绑定 fancyBox 事件:

<script type="text/javascript">
         $("[data-fancybox]").fancybox({
           // 这里是选项
         });
       </script>
       $(document).ready(function() { 
               
           $("a#single_image").fancybox();     
               
           $("a#inline").fancybox({
               'hideOnContentClick': true
           });
               
           $("a.group").fancybox({
               'transitionIn'  :   'elastic',
               'transitionOut' :   'elastic',
               'speedIn'       :   600, 
               'speedOut'      :   200, 
               'overlayShow'   :   false
           });
       });

Fancybox的API和配置选项参数说明

属性名默认值简要说明
padding10浏览框内边距,和css中的padding一个意思
margin20浏览框外边距,和css中的margin一个意思
opacityfalse如果为true,则fancybox在动画改变的时候透明度可以跟着改变
modalfalse如果为true,则'overlayShow' 会被设成 'true' , 'hideOnOverlayClick', 'hideOnContentClick', 'enableEscapeButton', 'showCloseButton' 会被设成 'false'
cyclicfalse如果为true,相册会循环播放
scrolling'auto'设置overflow的值来创建或隐藏滚动条,可以设置成 'auto', 'yes', or 'no'
width560设置iframe和swf的宽度,如果 'autoDimensions'为 'false',这也可以设置普通文本的宽度
height340设置iframe和swf的高度,如果 'autoDimensions'为 'false',这也可以设置普通文本的高度
autoScaletrue如果为true,fancybox可以自适应浏览器窗口大小
autoDimensionstrue在内联文本和ajax中,设置是否动态调整元素的尺寸,如果为true,请确保你已经为元素设置了尺寸大小
centerOnScrollfalse如果为true,当你滚动滚动条时,fancybox将会一直停留在浏览器中心
ajax{ }和jquery的ajax调用选项一样
注意: 'error' and 'success' 这两个回调事件会被fancybox重写
swf{wmode: 'transparent'}swf的设置选项
hideOnOverlayClicktrue如果为true则点击遮罩层关闭fancybox
hideOnContentClickfalse如果为true则点击播放内容关闭fancybox
overlayShowtrue如果为true,则显示遮罩层
overlayOpacity0.3遮罩层的透明度(范围0-1)
overlayColor'#666'遮罩层的背景颜色
titleShowtrue如果为true,则显示标题
titlePosition'outside'设置标题显示的位置.可以设置成 'outside', 'inside' 或 'over'
titleFormatnull可以自定义标题的格式
transitionIn, transitionOut'fade'设置动画效果. 可以设置为 'elastic', 'fade' 或 'none'
speedIn, speedOut300fade 和 elastic 动画切换的时间间隔, 以毫秒为单位
 
changeSpeed300切换时fancybox尺寸的变化时间间隔(即变化的速度),以毫秒为单位
changeFade'fast'切换时内容淡入淡出的时间间隔(即变化的速度)
easingIn, easingOut'swing'为 elastic 动画使用 Easing
showCloseButtontrue如果为true,则显示关闭按钮
showNavArrowstrue如果为true,则显示上一张下一张导航箭头
enableEscapeButtontrue如果为true,则启用ESC来关闭fancybox
onStartnull回调函数,加载内容是触发
onCancelnull回调函数,取消加载内容后触发
onCompletenull回调函数,加载内容完成后触发
onCleanupnull回调函数,关闭fancybox前触发
onClosednull回调函数,关闭fancybox后触发
 

超赞,真给力!嗯,必须鼓励~

打赏0
账号:mxy310@163.com[复制]
账号:77940140[复制]