FancyBox API列表

FancyBox是一个基于jQuery的图片轮播插件,可定制很强。下表是它的API列表。

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

advanced options

Key Description
type Forces content type. Can be set to 'image', 'ajax', 'iframe', 'swf' or 'inline'
href Forces content source
title Forces title
content Forces content (can be any html data)
orig Sets object whos position and dimensions will be used by 'elastic' transition
index Custom start index of manually created gallery (since 1.3.1)

公共方法

以下是fancybox提供的公共方法

Method Description
$.fancybox.showActivity Shows loading animation
$.fancybox.hideActivity Hides loading animation
$.fancybox.next Displays the next gallery item
$.fancybox.prev Displays the previous gallery item
$.fancybox.pos Displays item by index from gallery
$.fancybox.cancel Cancels loading content
$.fancybox.close Hides FancyBox 
Within an iframe use - parent.$.fancybox.close();
$.fancybox.resize Auto-resizes FancyBox height to match height of content 自适应高度
$.fancybox.center Centers FancyBox in viewport 让fancybox在网页中自动居中

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值