1
我试图采用我在this question中找到的脚本,但将图像更改为某些内容似乎比我想象的要困难。在鼠标移动时移动div
剧本很简单,应该对mousemove
的holder
内#content
DIV招:
// written by Roko C. Buljan
var $mmGal = $('#holder'),
$mmImg = $('#content'),
damp = 10, // higher number = smoother response
X = 0, Y = 0,
mX = 0, mY = 0,
wDiff, hDiff,
zeno;
function motion(){
zeno = setInterval(function(){ // Zeno's paradox "catching delay"
X += (mX-X)/damp;
Y += (mY-Y)/damp;
$mmGal.scrollLeft(X*wDiff).scrollTop(Y*hDiff);
}, 26);
}
// Get image size after it's loaded and run our fn
$mmImg.one('load', function() {
wDiff = (this.width/$mmGal.width())-1,
hDiff = (this.height/$mmGal.height())-1;
}).each(function() {
if(this.complete) $(this).load();
});
$mmGal.mousemove(function(e) {
mX = e.pageX-this.offsetLeft;
mY = e.pageY-this.offsetTop;
}).hover(function(e){
return e.type=='mouseenter'? motion() : setTimeout(function(){
clearInterval(zeno);
},1200); // clear if not used
});
为什么没有DIV #content
移动(文字和图片)?
你想要的内容移动或只图像? – xxCodexx
我想移动整个div#内容,所以文本和图像:) –