本文实例为大家分享了自己动手实现的jquery放大镜插件,供大家参考,具体内容如下
/**
***********************************************
**此插件使用须知--------------- **
**滤镜(inner)与其活动区(active)之比要等于 **
**放大区(movequ)与其内部图片之比。如比值不相 **
**等,请改变图片大小.------------------------**
**参数介绍 **
**active:滤镜活动区 **
**inner:滤镜 **
**movequ:放大区域 **
**需在Html头部引入本js脚本及jquery-1.8.3脚本 **
**如有疑问,请联系QQ:64047399,为你解答 **
***********************************************
**/
$.fn.extend({
yangbo:function(active,inner,movequ){
$(active).hover(function(){
$(inner).show();
$(movequ).show();
var proportionOne=$(active).width()/$(inner).width();
var proportionTwo=$(movequ).find('img').width()/$(movequ).width();
// console.log($(movequ).find('img').width());
if(proportionOne==proportionTwo){
$(this).mousemove(function(event){
//以下为右侧放大
var proportionLeft=$(active).width()/$(inner).width();
var proportionTop=$(active).height()/$(inner).height();
$(movequ).scrollLeft($(inner).position().left*proportionLeft).scrollTop($(inner).position()
.top*proportionTop);
//以下为小滤镜拖拽
$(inner).offset({
left:event.pageX-40,
top:event.pageY-40
});
//以下为判断临界值
if($(inner).position().left<=0){
$(inner).css({
left:0
})
}
if($(inner).position().top<=0){
$(inner).css({
top:0
})
}
if($(inner).position().left>=$(this).width()-$(inner).width()){
$(inner).css({
left:$(this).width()-$(inner).width()
})
}
if($(inner).position().top>=$(this).height()-$(inner).height()){
$(inner).css({
top:$(this).height()-$(inner).height()
})
}
})
}else{
$(active).text('图片宽高不正确:请调整图片宽高-->滤镜与其父亲之比应该等于右侧盒子与右侧图片之比')
.css({
background:'yellow',
color:'red',
});
}
},function(){
$(inner).hide();
$(movequ).hide();
})
}
})
以上就是本文的全部内容,希望对大家的学习有所帮助。
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件!
如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
桃源资源网 Design By www.nqtax.com
暂无“基于jquery编写的放大镜插件”评论...
RTX 5090要首发 性能要翻倍!三星展示GDDR7显存
三星在GTC上展示了专为下一代游戏GPU设计的GDDR7内存。
首次推出的GDDR7内存模块密度为16GB,每个模块容量为2GB。其速度预设为32 Gbps(PAM3),但也可以降至28 Gbps,以提高产量和初始阶段的整体性能和成本效益。
据三星表示,GDDR7内存的能效将提高20%,同时工作电压仅为1.1V,低于标准的1.2V。通过采用更新的封装材料和优化的电路设计,使得在高速运行时的发热量降低,GDDR7的热阻比GDDR6降低了70%。