jQuery和CSS创建平滑 图像缩放和平移效果 EasyZoom

  • 源码大小:1.98MB
  • 所需积分:1积分
  • 源码编号:19JP-3244
  • 浏览次数:1021次
  • 最后更新:2023年05月21日
  • 所属栏目:缩放
本站默认解压密码:19jp.com 或 19jp_com

简介

EasyZoom是一个轻量级且与触摸兼容的jQuery缩放插件,允许您在触摸设备上使用鼠标光标或手指缩放和平移图像。

基本用法:

1.在网页的首页部分包含jQuery easyZoom插件的CSS文件。

  1. <link rel="stylesheet" href="/path/to/css/easyzoom.css" />

2.在网页末尾包含jQuery库和jQuery easyZoom插件的脚本。

  1. <script src="/path/to/cdn/jquery.min.js"></script>
  2. <script src="/path/to/dist/easyzoom.js"></script>

3.向原始图像添加链接,并将其包装在easyZoom包装中,该包装将显示一个覆盖,用于检查缩放图像是否已加载。

  1. <div class="easyzoom easyzoom--overlay">
  2. <a href="larger.jpg">
  3. <img src="standard.jpg" alt="" width="640" height="360" />
  4. </a>
  5. </div>

4.使用默认选项初始化插件。

  1. $(function(){
  2. $('.easyzoom').easyZoom();
  3. });

5.可用选项和回调功能

  1. $('.easyzoom').easyZoom({
  2.  
  3. // The text to display within the notice box while loading the zoom image.
  4. loadingNotice: 'Loading image',
  5.  
  6. // The text to display within the notice box if an error occurs when loading the zoom image.
  7. errorNotice: 'The image could not be loaded',
  8.  
  9. // The time (in milliseconds) to display the error notice.
  10. errorDuration: 2500,
  11.  
  12. // Attribute to retrieve the zoom image URL from.
  13. linkAttribute: 'href',
  14.  
  15. // Prevent clicks on the zoom image link.
  16. preventClicks: true,
  17.  
  18. // Callback function to execute before the flyout is displayed.
  19. beforeShow: $.noop,
  20.  
  21. // Callback function to execute before the flyout is removed.
  22. beforeHide: $.noop,
  23.  
  24. // Callback function to execute when the flyout is displayed.
  25. onShow: $.noop,
  26.  
  27. // Callback function to execute when the flyout is removed.
  28. onHide: $.noop,
  29.  
  30. // Callback function to execute when the cursor is moved while over the image.
  31. onMove: $.noop
  32. });

更新日志:

v2.6.0版本(2022-12-30)

  • 使现代化

v2.5.3版本(2020-05-15)

  • 修复混合的X和Y变量

v2.5.2版本(2018-11-23)

  • 使现代化

v2.5.1版本(2018-10-04)

  • 用于计算光标位置的目标元素的用户外部宽度

v2.5.0版本(2017-02-15)

  • 使现代化

v2.4.0版本(2016-04-19)

  • 使现代化

v2.3.0版本(2015-03-16)

  • 使现代化

v2.2.1版本(2014-09-16)

  • 修复鼠标相对位置为负值的问题

预览截图