【发布时间】:2014-04-04 21:15:36
【问题描述】:
有问题的代码使页面滚动到页面上的特定点。正如标题所说,我希望 Google Closure 等同于以下 jQuery:
$('html,body').animate({scrollTop: 800});
它说here html, body 允许浏览器不一致,而$(document) 是等效的。
我尝试了以下方法:
var anim = new goog.fx.dom.Scroll(document, [0, 0], [0, 800], 400);
anim.play();
我也试过document.body。
goog.fx.dom.Scroll 在网络上没有演示,而且信息非常缺乏。
【问题讨论】:
-
我假设基于 api 您需要调用它两次,一次使用
document.body,再次使用document.querySelector("html"),但我从未使用过该库。 -
你最好问问closure-library-discuss@
-
@John 感谢您的建议 :)
-
为了记录,我最终通过使用 Chris Ferdinandi 的 jQuery 平滑滚动插件的修改、硬编码、de-jQueried 版本来使用 Vanilla。
标签: javascript jquery animation scroll google-closure