1.1.7 • Published 8 years ago

jzoom v1.1.7

Weekly downloads
8
License
MIT
Repository
github
Last release
8 years ago

#jZoom

A tiny and easy-using jQuery plugin for zooming images

##Index

###中文说明

##Quick start

###Install by npm or bower

$ npm install jzoom
$ bower install jzoom

###Include files

<script src="jquery.min.js"></script>
<script src="jzoom.js"></script>

Call the plugin on an image's container as simple as

$('#container').jzoom();

All done !

##Options

Custom the plugin with available options which are listed below.

$('#container').jzoom({
    option: value,
    option2: value2,
    ...
});
OptionTypeDefaultDescription
widthNumber400The width of zooming window.
heightNumber400The height of zooming window.
positionString"right"The relative positon to the zoomed image or container. "top", "bottom" and "left" are permitted.
offsetXNumber20The deviation on X-asix, can't be negative.
offsetYNumber0The deviation on Y-asix, can't be negative.
opacityNumber0.6The opacity of lens div.
bgColorString"#fff"The background color of lens div.
loadingString"Loading..."The loading text on zooming window when big image is loading.
suffixNameString"_big"The suffix name of big image.
imgTypeStringthe zoomed image typeThe type of big image. The default option is recommended.

##Attentions

  1. No CSS needed.

  2. The container will be added position: relative if it's not positioned.

  3. For getting best effect, the big image and the zoomed image should be requested:

    • filenames: If the filename of the zoomed image is "image", then the big image should be "image + suffix name".
    • types: The same types were recommended because some bugs may appear on IE.
    • In same folder.

##License

MIT License


###使用说明

###通过 npm 或 bower 安装

$ npm install jzoom
$ bower install jzoom

###引入文件

<script src="jquery.min.js"></script>
<script src="jzoom.js"></script>

然后在想要放大的图片的容器上调用插件,

$('#container').jzoom();

即可实现默认效果。

###配置选项

自定义插件时,需要在方法中传入一个对象,可配置的选项列于下表。

$('#container').jzoom({
    option: value,
    option2: value2,
    ...
});
选项类型默认值描述
widthNumber400放大镜窗口的宽度
heightNumber400放大镜窗口的高度
positionString"right"放大镜窗口相对于图片或容器的位置,还可设置为"top", "bottom", "left"
offsetXNumber20放大镜窗口在水平方向上的偏移,不能为负
offsetYNumber0放大镜窗口在垂直方向上的偏移,不能为负
opacityNumber0.6镜头div的透明度
bgColorString"#fff"镜头div的背景色
loadingString"Loading..."加载图片时显示的文字,水平垂直居中
suffixNameString"_big"大图后缀名
imgTypeString原图格式大图的格式,建议与原图相同

###注意事项

  1. CSS部分代码已完全集成到JS代码中。

  2. 如果图片容器没有进行定位,则会默认添加position: relative属性。

  3. 大图与原图之间需要有一定的对应关系:

    • 名称:如原图的文件名为image,则大图的文件名需为“image + 后缀名” 。
    • 格式:大图与原图的格式建议相同,因为在IE下有时会出现bug。
    • 位于同一目录下。

##开源协议

基于 MIT 协议