我在绝对位置和 translateY()
有3个div 在 requestAnimationFrame上我通过相对于鼠标位置的 translateY() css声明 移动它们 但是对于我的生活,我无法弄清楚如何在传递视口后循环div我在 requestAnimationFrame
中有以下代码street.each(function(i,el){ // an array of the divs
var bounds = el.getBoundingClientRect(); // get the bounds
// here is where it gets tricky. i'm trying to detect when the div's view port has passed
// the screen so as to start it over
var yPos = bounds.top >= h? -y - bounds.height * 2 : (y - bounds.height * i); // y is the position of the mouse from 0,0
$(el).css($.fx.cssPrefix + 'transform','translateY(' + yPos +'px)'); // set the translation of Y
//console.log('street',i,'y', y, 'top: ', bounds.top, 'bottom',bounds.bottom,);
});