2011-03-02 215 views
0

我試圖獲取JavaScript頁面滾動到目標位置,這樣的:滾動到位置(JavaScript)的

scrollbarxpos += (targetscrollbarxpos - scrollbarxpos)/100.0f; 

而且基本保持調用該行代碼,直到scrollbarxpos = targetscrollbarxpos。

任何想法我可以怎麼做呢?

回答

2

你看過scrollTo函數嗎?它允許您使用x或y座標滾動到頁面上的某個位置。如果要爲動畫滾動顯示動畫,可以使用setIntervalclearInterval的某種組合,撥打scrollTo,直到達到所需的y位置。