MooTools onLoad 平滑滚动

SmoothScroll 是一个很棒的 MooTools 插件,但只有当锚点在同一页面上时才会出现平滑滚动。让 SmoothScroll 跨页面工作就像多加几行 MooTools 和一个查询字符串变量一样简单。

MooTools / PHP

//once the DOM is ready...
window.addEvent('domready', function() { 
	//smooooooth scrolling enabled
	new SmoothScroll({ duration:700 }, window); 
});

<?php if($_GET['scrollto']) { ?>
//once the window has loaded...
window.addEvent('load', function() {
	//scroll down to the specific spot
	var scroll = new Fx.Scroll(window, { wait: false, duration: 2500, transition: Fx.Transitions.Quad.easeInOut });
	scroll.toElement('<?php echo $_GET['scrollto']; ?>');
});
<?php } ?>

当然,这是一个您只想在锚点很少的小型网站上实施的系统。

赞(0) 打赏

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

微信扫一扫打赏