html鼠标悬停图片抖动,鼠标悬停时图像抖动

它不断抖动的原因是插件被设置为创建一个间歇性抖动的元素。永远。奶昔是用

从工作

整个的

有人盘旋的时候…你…吗?那太烦人了)

把你想要振动的东西放在一个分区里,用

$('#jquery-vibrate-example').hover(function() {$(this).vibrate();});

$('#jquery-vibrate-example').mouseenter(function() {$(this).vibrate();});

当你打电话

.vibrate()

您可以将速度、持续时间和传播(我删除了频率)作为对象文字的一部分传入,以微调振动:

$(this).vibrate({"speed":100,"duration":800,"spread":5});

例如。更大的

speed

震动越慢,因为

速度

直接用于

setInterval()

颤抖的声音。另外两个是不言而喻的:

jQuery.fn.vibrate = function (conf) {

var config = jQuery.extend({

speed: 30,

duration: 1000,

spread: 3

}, conf);

return this.each(function () {

var t = jQuery(this);

var vibrate = function () {

var topPos = Math.floor(Math.random() * config.spread) - ((config.spread - 1) / 2);

var leftPos = Math.floor(Math.random() * config.spread) - ((config.spread - 1) / 2);

var rotate = Math.floor(Math.random() * config.spread) - ((config.spread - 1) / 2);

t.css({

position: 'relative',

left: leftPos + 'px',

top: topPos + 'px',

WebkitTransform: 'rotate(' + rotate + 'deg)' // cheers to erik@birdy.nu for the rotation-idea

});

};

var doVibration = function () {

var vibrationInterval = setInterval(vibrate, config.speed);

var stopVibration = function () {

clearInterval(vibrationInterval);

t.css({

position: 'static',

WebkitTransform: 'rotate(0deg)'

});

};

setTimeout(stopVibration, config.duration);

};

doVibration();

});

};

注:

该插件将您的震动项的位置更改为

relative

…所以如果你把它应用到

absolute

定位元件。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值