Zooming 是一款纯 javascript 图片缩放库,主要特点有:

  • 不依赖其他库,纯 JavaScript 实现,支持移动设备;
  • 流畅的动画;
  • 可缩放高清图像;
  • 易于集成和定制。
  • 使用方法

    1、引入文件

    <script src="js/zooming.min.js"></script>

    2、HTML

    <a href="images/1.jpg">
    <img class="img-zoomable" src="data:images/1s.jpg" alt="">
    </a>

    或者使用 data 属性:

    <img src="data:images/2s.jpg" data-action="zoom" data-original="images/2.jpg" alt="">

    3、JavaScript

    var zooming = new Zooming();
    zooming.listen('.img-zoomable');

    配置

    属性

    名称 类型 默认值 说明
    defaultZoomable 字符串 img[data-action=”zoom”] 缩放元素,可以是 css 选择器
    enableGrab 布尔值 true 是否能够抓取移动
    preloadImage 布尔值 true 是否预加载图片
    transitionDuration 整数/小数 0.4 动画持续时间
    transitionTimingFunction 字符串 cubic-bezier(0.4, 0, 0, 1) 动画函数
    bgColor 字符串 rgb(255, 255, 255) 遮罩背景颜色
    bgOpacity 整数/小数 1 遮罩透明度
    scaleBase 整数/小数 1 缩放比例,默认为适应窗口大小
    scaleExtra 整数/小数 0.5 抓取图像时额外缩放比例
    scrollThreshold 整数 40 关闭前需要多少滚动
    customSize   null 缩放到指定的宽度和高度,如果设置该属性,将忽略 scaleBase 属性
    onOpen   null 放大后的回调函数
    onClose   null 关闭后的回调函数
    onRelease   null 松开后的回调函数
    onBeforeOpen   null 放大前的回调函数
    onBeforeClose   null 关闭前的回调函数
    onBeforeGrab   null 抓取前的回调函数
    onBeforeMove   null 移动前的回调函数
    onBeforeRelease   null 松开前的回调函数

演示地址:http://www.dowebok.com/demo/223/

GitHub 地址:https://github.com/kingdido999/zooming

Zooming的更多相关文章

  1. mouse scrollings and zooming operations in linux & windows are opposite

    mouse scrollings and zooming operations in linux & windows are opposite. windows中, 鼠标滚动的方向是: 查看页 ...

  2. ion-scroll zooming="true" android端无法缩放的问题

    很久很久没更新博客了,从今天开始决定以后陆续写一些博文,总结下自己在开发中碰到的问题. ionic项目.ion-scroll zooming="true" 在android端无法缩 ...

  3. 数字图像处理实验(4):PROJECT 02-04 [Multiple Uses],Zooming and Shrinking Images by Bilinear Interpolation 标签: 图像处理MATLAB

    实验要求: Zooming and Shrinking Images by Bilinear Interpolation Objective To manipulate another techniq ...

  4. 数字图像处理实验(3):PROJECT 02-03, Zooming and Shrinking Images by Pixel Replication 标签: 图像处理matlab 20

    实验要求: Zooming and Shrinking Images by Pixel Replication Objective To manipulate a technique of zoomi ...

  5. Zooming MKMapView to fit annotation pins

    http://stackoverflow.com/questions/4680649/zooming-mkmapview-to-fit-annotation-pins - (MKCoordinateR ...

  6. pycharm Zooming in the Editor

    https://www.jetbrains.com/help/pycharm/zooming-in-the-editor.html To enable changing font size in th ...

  7. JavaScript资源大全中文版(Awesome最新版)

    Awesome系列的JavaScript资源整理.awesome-javascript是sorrycc发起维护的 JS 资源列表,内容包括:包管理器.加载器.测试框架.运行器.QA.MVC框架和库.模 ...

  8. HTML5 网络拓扑图性能优化

    HTML5 中的 Canvas 对文本的渲染(fillText,strokeText)性能都不太好,比如设置字体(font).文本旋转(rotation),如果绘制较多的文本时,一些交互操作会手动很大 ...

  9. 20个不可思议的 WebGL 示例和演示

    WebGL 是一项在网页浏览器呈现3D画面的技术,有别于过去需要安装浏览器插件,通过 WebGL 的技术,只需要编写网页代码即可实现3D图像的展示.WebGL 可以为 Canvas 提供硬件3D加速渲 ...

随机推荐

  1. ELK系列一:ELK的安装

    一.Elasticsearch.Kibana.Logstash.Elasticsearch-head的安装 ELK的安装 安装下载地址: https://www.elastic.co/cn/downl ...

  2. Unity3D Android动态反射加载程序集

    这种办法在iOS下是不让用的,只能在Android下用.用起来也很方便了. 1.先创建一个c#工程,引用到的UnityEngine.dll在Unity的安装目录里找吧 2.将编译的dll放入Unity ...

  3. MFC修改窗口无标题和标题信息,修改执执行文件图标

    一.创建MFC后 窗口显示的是 无标题-工程名 修改方法在网上看到了几种,下面介绍下比较简单的一种: 1.在MianFrame.c文件中找到这个函数 BOOL CMainFrame::PreCreat ...

  4. Spark2 SQL configuration参数配置

    查看当前环境SQL参数的配置 spark.sql("SET -v") key value spark.sql.hive.version 1.2.1 spark.sql.source ...

  5. jQuery生成一个DIV容器,ID是"rating".

    我们需要一些服务器端代码,这个例子中用到了一个PHP文件,读取rating参数然后返回rating总数和平均数.看一下rate.php代码.虽然这些例子也可以不使用AJAX来实现,但显示我们不会那么做 ...

  6. NEFU 118 - n!后面有多少个0 & NEFU 119 - 组合素数 - [n!的素因子分解]

    首先给出一个性质: n!的素因子分解中的素数p的幂为:[ n / p ] + [ n / p² ] + [ n / p³ ] + …… 举例证明: 例如我们有10!,我们要求它的素因子分解中2的幂: ...

  7. Python 文件内容读取

    # 读取数据的函数 def readData(filename): with open(filename, 'r') as f: data = f.read().lower() data = list ...

  8. Codeforces Round #433 (Div. 2, based on Olympiad of Metropolises)

    A. Fraction 题目链接:http://codeforces.com/contest/854/problem/A 题目意思:给出一个数n,求两个数a+b=n,且a/b不可约分,如果存在多组满足 ...

  9. 洛谷 P4697 Balloons [CEOI2011] 单调栈/dp (待补充qwq)

    正解:单调栈/dp 解题报告: 先放个传送门qwq 话说这题是放在了dp的题单里呢?但是听说好像用单调栈就可以做掉所以我就落实下单调栈的解法好了qwq (umm主要如果dp做好像是要斜率优化凸壳维护双 ...

  10. 给sql server2005打补丁报错:无法安装Windows Installer MSP文件

    给sql server2005打补丁报错:无法安装Windows Installer MSP文件 在我们安装完SQL2005数据库后,需要安装SP4补丁时,会出错:无法安装Windows Instal ...