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#內容,所以文本和圖像:) –