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. stdarg.h头文件源代码分析

    谈到C语言中可变参数函数的实现(参见C语言中可变参数函数实现原理),有一个头文件不得不谈,那就是stdarg.h 本文从minix源码中的stdarg.h头文件入手进行分析: #ifndef _STD ...

  2. Mac Lion Configure Apache

    mkdir ~/Sites echo "<html><body><h1>My site works</h1></body>< ...

  3. !important:element.style 覆盖样式问题

    问题: 浏览器F12看到是这个样子. 但是我设置的样式是这样子. #iframe_close { width:750px; } 无论怎么设置样式,都无法覆盖掉element.style的样式,widt ...

  4. jQuery:find()方法与children()方法的区别

    1:children及find方法都用是用来获得element的子elements的,两者都不会返回 text node,就像大多数的jQuery方法一样. 2:children方法获得的仅仅是元素一 ...

  5. 【CF815D】Karen and Cards 单调栈+扫描线

    [CF815D]Karen and Cards 题意:一张卡片有三个属性a,b,c,其上限分别为A,B,C,现在有n张卡片,定义一张卡片能打败另一张卡片当且仅当它的至少两项属性要严格大于另一张的对应属 ...

  6. MAC 安装ram

    RVM 是干什么的这里就不解释了,后面你将会慢慢搞明白. $ curl -L https://get.rvm.io | bash -s stable 期间可能会问你sudo管理员密码,以及自动通过ho ...

  7. 7.22 python线程(3)

    2018-7-22 10:28:29 回来啦! 6.条件 # !/usr/bin/env python # !--*--coding:utf-8 --*-- # !@Time :2018/7/20 1 ...

  8. 2018-2019-2 20165330《网络对抗技术》Exp4 恶意代码分析

    目录 基础问题 相关知识 实验目的 实验内容 实验步骤 实验过程中遇到的问题 实验总结与体会 实验目的 监控你自己系统的运行状态,看有没有可疑的程序在运行 分析一个恶意软件,就分析Exp2或Exp3中 ...

  9. 2018牛客网暑期ACM多校训练营(第四场) A - Ternary String - [欧拉降幂公式][扩展欧拉定理]

    题目链接:https://www.nowcoder.com/acm/contest/142/A 题目描述 A ternary string is a sequence of digits, where ...

  10. HDU 1890 - Robotic Sort - [splay][区间反转+删除根节点]

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1890 Time Limit: 6000/2000 MS (Java/Others) Memory Li ...