jquery自定义动画的函数切换函数
来源:互联网 发布:餐厅进销存软件 编辑:程序博客网 时间:2024/06/05 03:15
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); }})