jQuery.fn.extend({
//判断当前鼠标所在的位置是否存在某个对象的区域范围内
mouseIsRange: function(e) {
var offset = $(this).offset();
var oWidth = parseInt($(this).width());
var oHeight = parseInt($(this).height());
var mouseX = parseInt(e.pageX);
var mouseY = parseInt(e.pageY);
//alert(oWidth+'||'+oHeight+'||'+mouseX+'||'+mouseY);
//alert((offset.left<=mouseX)+'||'+((offset.left+oWidth)>=mouseX)+'||'+(offset.top<=mouseY)+'||'+((offset.top+oHeight)>=mouseY)+'||'+offset.left+'||'+mouseX+'||'+oWidth);
if ((offset.left <= mouseX) && ((offset.left + oWidth) >= mouseX) && (offset.top <= mouseY) && ((offset.top + oHeight) >= mouseY)) {
return 1;
} else {
return 0;
}
},
//创建自定义动画的函数切换函数
animateToggle: function(params, speed, easing, fn) {
for (var i in params) {
if (!($(this).data('this_' + i))) {
$(this).data('this_' + i, $(this).css(i));
} else {
if ($(this).data('this_' + i) != $(this).css(i)) {
params[i] = $(this).data('this_' + i);
}
if (parseInt($(this).css(i)) != parseInt(params[i])) {
$(this).data('this_' + i, $(this).css(i));
}
}
}
$(this).animate(params, speed, easing, fn);
}
})
jquery自定义动画的函数切换函数
最新推荐文章于 2023-02-23 17:52:37 发布