jQuery图片放大预览插件 cloud-zoom

本文介绍了一款基于jQuery的图片放大预览插件cloud-zoom,并提供了详细的部署步骤及参数说明,帮助开发者轻松实现图片放大的交互效果。

分享一个jquery的图片放大预览插件:cloud-zoom.

cloud-zoom DEMO

部署步骤:

1.加载jquery-1.4.js 和 cloud-zoom.1.0.2.min.js

2.加入样式表(DEMO中<style>部分)

3.为需要放大预览效果的缩略图添加超链接<a> 并将类命名为”cloud-zoom” class=”cloud-zoom”

4.在超链接<a> 的rel属性中加入需要的参数实现不同的效果

实例:

<a href=”images/大图.jpg” class=”cloud-zoom” rel=”position:’inside’ ,showTitle:false, adjustX:-2, adjustY:-2″><img src=”images/缩略图.jpg” title=”iinterest” /></a>

cloud-zoom参数说明:

ParameterDescription (from V1.0.0)Default Value
zoomWidthThe width of the zoom window in pixels. If ‘auto’ is specified, the width will be the same as the small image.‘auto’
zoomHeightThe height of the zoom window in pixels. If ‘auto’ is specified, the height will be the same as the small image.‘auto’
positionSpecifies the position of the zoom window relative to the small image. Allowable values are ‘left’, ‘right’, ‘top’, ‘bottom’, ‘inside’ or you can specifiy the id of an html element to place the zoom window in e.g. position: ‘element1′‘right’
adjustXAllows you to fine tune the x-position of the zoom window in pixels.0
adjustYAllows you to fine tune the y-position of the zoom window in pixels.0
tintSpecifies a tint colour which will cover the small image. Colours should be specified in hex format, e.g. ‘#aa00aa’. Does not work with softFocus.false
tintOpacityOpacity of the tint, where 0 is fully transparent, and 1 is fully opaque.0.5
lensOpacityOpacity of the lens mouse pointer, where 0 is fully transparent, and 1 is fully opaque. In tint and soft-focus modes, it will always be transparent.0.5
softFocusApplies a subtle blur effect to the small image. Set to true or false. Does not work with tint.false
smoothMoveAmount of smoothness/drift of the zoom image as it moves. The higher the number, the smoother/more drifty the movement will be. 1 = no smoothing.3
showTitleShows the title tag of the image. True or false.true
titleOpacitySpecifies the opacity of the title if displayed, where 0 is fully transparent, and 1 is fully opaque.0.5
附加JavaScript和CSS文件到你的文档。编辑CSS文件并且 匹配你的图片路径,同时改变颜色匹配你网站的主题 重要:像例子中一样确定包含的JavaScript文件 具体顺序。 <link rel="stylesheet" media="screen" type="text/css" href="css/zoomimage.css" />[removed][removed][removed][removed][removed][removed]调用代码 你所需要做的所有事就是使用jQuery的方式选择一个元素并且调用插件。 $('a.myLinks').zoomimage(options); 可选项 一个哈希参数。所有的参数都是可选的。 Opacity float 控制栏和标题栏的不透明度。默认: 0.3 border integer 图片的边框宽度。默认: 0 duration integer 动态化持续时间。默认: 300 译者注:控制图片放大的时间和标题栏、控制栏显示的时间,两个操作不同步进行。 easing string 动画缓和。默认: linear prevent integer 拖动图像前忽略的位移像素(防止鼠标的意外拖动所用)。默认: 14 译者注:防止鼠标按下后意外移动导致图像发生位移。 controls boolean 是否显示控制条(如果一个图片组中只有一张图片,则控制条不显示)。默认: true caption boolean 是否显示标题(标题的内容来源于a标签的title属性)。默认: true centered boolean 图片放大后是否在浏览器中心显示。默认: false hideSource boolean 图片放大后是否影藏原微缩图像。默认: false className string 用户自定义的CSS样式名。默认: false。 译者注:false时使用zoomimage.css文件,className即为css文件名同时也是css类名。 controlsTrigger string 控制标题的显示样式,'focus'图像获取到焦点是显示标题,'mouseover'鼠标悬停在图片上时显示标题。默认: 'focus' preload string 预处理,'click'当点击是加载图片 ,'load'文档载入时就加载图片。默认: 'click' onLoad function 回调函数,当图像被加载的时候触发 beforeZoomIn function 回调函数,在图像被放大前触发 onZoomIn function 回调函数,在图像被放大时触发 beforeZoomOut function 回调函数,在图像被缩小前触发 onZoomOut function 回调函数,在图像被缩小时触发 onFocus function 回调函数,当图片获取焦点时触发 关闭所有图片或移除节点 如果你想关闭所有打开的图片或像不通过触发器清除图片(从DOM移除),那么你可以使用 'zoomimageClear'。这个插件的这个选择器永远是 'div.zoomimage'. $('div.zooimage').zoomimageClear();阴影设置 你可以自定义阴影。要做到这一点你必须明白如何布局框来呈现阴影。 每个CSS类负责一个特定区域的阴影。你可以在类中改变背景图片的位置和大小。
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值