/** * @param target a jQuery selector string, target DOM; or scrollTop value * @param container a jQuery selector string, represents DOM which contains target, default is 'html, body' */ function smoothScrollTo(target, container) { container = container ? container : 'html, body'; $(container).animate({ scrollTop: $.isNumeric(target) ? target : $(target).offset().top + $(container).scrollTop() - $(container).offset().top }, 300); } // Ex: smoothScrollTo('#anchor');
2013/08/10
用jQuery寫出scrolling動畫效果
網路上的範例大多以body為容器,稍微修改了一下以適應在其他DOM內的scrolling效果:
This page is made to demonstrate what i learned from some popular javascript library/framework. For now, it used H5BP as basic template, Bootstrap for layout and CSS style, and jQuery. (Backbone.js is going to be added for MVC implemenation)
This page is made to demonstrate what i learned from some popular javascript library/framework. For now, it used H5BP as basic template, Bootstrap for layout and CSS style, and jQuery. (Backbone.js is going to be added for MVC implemenation)
This page is made to demonstrate what i learned from some popular javascript library/framework. For now, it used H5BP as basic template, Bootstrap for layout and CSS style, and jQuery. (Backbone.js is going to be added for MVC implemenation)
標籤:
javascript,
jQuery,
programming
訂閱:
張貼留言 (Atom)
沒有留言:
張貼留言