如何将 div View 的动画滚动到特定的 x 和 y 坐标。
this.onClickButtonArrows1 = function ( element, scrollDirection )
{
if( scrollDirection == "down")
{
var element1 = document.getElementById('shape_74');
var position = element1.getBoundingClientRect();
var x_pos = position.left;
var y_pos = position.top;
$(element).animate({ top: y_pos+'px', left: x_pos+'px' }, 1000);
}
}
最佳答案
使用scrollIntoView()
var element = document.getElementById("box");
element.scrollIntoView({
behavior: "smooth",
block: "end",
inline: "nearest"
});
关于javascript - 如何将 div View 的动画滚动到特定的 x 和 y 坐标,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58950288/