Dojo Smooth Scrolling

Written by on November 14th, 2006 in Ajax News.

There have been requests for smooth scrolling widgets in Dojo, and Heng Liu stood up tot he plate by implementing dojo.lfx.smoothScroll.

Along with this new dojo.lfx resource, other improvements include:

  • dojo.html.getAbsolutePosition is extended to be compatible with dojo.withGlobal
  • a new function, dojo.html.getAbsolutePositionExt is introduced in resource dojo.html.util to include support for getting abosolute postion of a node in iframes with regards to a given window. The reason why this is not merged into dojo.html.getAbsolutePosition is that, this new feature depends on APIs defined in dojo.html.util. In order to avoid introducing it as a dependency in dojo.html.layout, this design decision is made.

To see it in action check out this test page and click on the buttons on the top left to see the items scroll.

Example Usage

dojo.event.connect(dojo.byId(”goToHeader0″), “onclick”, function (e) {
        var h2s = dojo.html.iframeContentDocument(dojo.byId(”embed0″)).getElementsByTagName(’h2′);
        var h2 = h2s[h2s.length-1];
        var anm = new dojo.lfx.smoothScroll(h2,dojo.html.iframeContentWindow(dojo.byId(”embed0″)),null,500);
        anm.play();
});
 

The entire thing is pretty small, take a peek for yourself

Source: Ajaxian
Original Article: http://ajaxian.com/archives/dojo-smooth-scrolling

Leave a Reply

You must be logged in to post a comment.



Site Navigation