php设计图片对比,jQuery实现的原图对比窗帘效果_jquery

效果:

7b91e07be033148a5bf404660bae0cc2.gif

HTML代码:

VFX-before.jpg

VFX-after.jpg

JS代码:

$(function () {

//外DIV

var imageWrap = $('.vfx-image-wrap'),

//前景图

topImage = $(this).find('.before-image'),

//分割线

divider = $(this).find('.divider-bar'),

stayBounce = $('.toggle-function');

imageWrap.on("mousemove", function (e) {

// Gotta localize top image and divider so it only applies to this

var offsets = $(this).offset(),

fullWidth = $(this).width(),

mouseX = e.pageX - offsets.left,

topImage = $(this).find('.before-image'),

divider = $(this).find('.divider-bar');

if (mouseX < 0) {

mouseX = 0;

} else if (mouseX > fullWidth) {

mouseX = fullWidth

}

$(this).addClass('special');

divider.css({ left: mouseX, transition: 'none' });

topImage.css({ width: mouseX, transition: 'none' });

});

stayBounce.click(function(){

$(this).toggleClass('stay');

});

imageWrap.on("mouseleave", function () {

if (!stayBounce.hasClass('stay')) {

divider.css({ left: '50%', transition: 'all .3s' });

topImage.css({ width: '50%', transition: 'all .3s' });

}

});

});

本文原创发布php中文网,转载请注明出处,感谢您的尊重!

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值