jQuery Zoom 图片聚焦或者点击放大A plugin to enlarge images on touch, click, or mouseover

jQuery Zoom是一个用于在触摸、点击或鼠标悬停时放大图片的插件,兼容Chrome, Firefox, Safari, Opera和IE7+。安装可通过NPM,适用于`<div>`, `<a>`, `<img>`等元素,不适用于`<input>`元素。当需要使用在`<input>`元素上时,需要包裹其他元素。可以通过触发`removeZoom`事件来移除插件效果。" 111991342,10396416,理解与配置VLAN:从交换机到路由器,"['网络', '交换机配置', '路由器配置', 'VLAN路由', 'DHCP']

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

Selection_058

 

 

下载: zoom-master

 

项目地址: https://github.com/jackmoore/zoom

 

Compatible with: jQuery 1.7+ in Chrome, Firefox, Safari, Opera, Internet Explorer 7+.

 
Install via NPM
npm install jquery-zoom

 

Instructions

Zoom appends html inside the element it is assigned to, so that element has to be able to accept html, like <a>, <span>, <li>, <div>, etc. This excludes <img> elements (see below).

// Example:
$(document).ready(function(){
  $('a.photo').zoom({url: 'photo-big.jpg'});
});

// Using Colorbox with Zoom
$(document).ready(function(){
  $('a.photo').zoom({
    url: 'photo-big.jpg', 
    callback: function(){
      $(this).colorbox({href: this.src});
    }
  });
});

 

 

To use zoom with img elements, they will need to be wrapped with another element. It is impossible to read some layout related CSS styles from JavaScript (percent-based width and height, margins set to auto, etc.) so the safe thing to do is to defer this change to individual site owners. The following is all that is needed in some cases:

$(document).ready(function(){
  $('img')
    .wrap('<span style="display:inline-block"></span>')
    .css('display', 'block')
    .parent()
    .zoom();
});

 

 

Removing Zoom

Trigger the zoom.destroy event to remove zoom from an element:

$('#example').zoom(); // add zoom
$('#example').trigger('zoom.destroy'); // remove zoom

 

 

Settings

PropertyDefaultDescription
urlfalseThe url of the large photo to be displayed. If no url is provided, zoom uses the src of the first child IMG element inside the element it is assigned to.
on'mouseover'The type of event that triggers zooming. Choose from mouseover, grab, click, or toggle.
duration120The fadeIn/fadeOut speed of the large image.
targetfalseA selector or DOM element that should be used as the parent container for the zoomed image.
touchtrueEnables interaction via touch events.
magnify1This value is multiplied against the full size of the zoomed image. The default value is 1, meaning the zoomed image should be at 100% of its natural width and height.
callbackfalseA function to be called when the image has loaded. Inside the function, `this` references the image element.
onZoomInfalseA function to be called when the image has zoomed in. Inside the function, `this` references the image element.
onZoomOutfalseA function to be called when the image has zoomed out. Inside the function, `this` references the image element.

 

原文: http://www.jacklmoore.com/zoom/

本文: jQuery Zoom 图片聚焦或者点击放大A plugin to enlarge images on touch, click, or mouseover

 

 

 

 

 

 

 

 

 

 

 

 

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值