Tuesday, November 14th, 2006

Dojo Smooth Scrolling

Category: Component, Dojo, JavaScript

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


  1. dojo.event.connect(dojo.byId("goToHeader0"), "onclick", function (e) {
  2.     var h2s = dojo.html.iframeContentDocument(dojo.byId("embed0")).getElementsByTagName('h2');
  3.     var h2 = h2s[h2s.length-1];
  4.     var anm = new dojo.lfx.smoothScroll(h2,dojo.html.iframeContentWindow(dojo.byId("embed0")),null,500);
  5.     anm.play();
  6. });

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

Posted by Dion Almaer at 12:27 pm

3.7 rating from 44 votes


Comments feed TrackBack URI

Dojo Smooth Scrolling

This is pretty cool, but it’s pretty easy to implement with jQuery or any other Frameworks out there.

Trackback by Programming in the State of 70% Drunkeness — November 14, 2006

[…] Ajaxian » Dojo (tags: Development_Ajax_Dojo) […]

Pingback by links for 2006-11-15 at Amy Stephen — November 15, 2006

Hmmm… I’m a bit confused by all the red text which says ‘This should be green’.

Is that a problem or just to make people like me confused?!

Comment by Dan Atkinson — November 16, 2006

Leave a comment

You must be logged in to post a comment.