73ad41a1e0baaec464619d9aa93c8d4a49065eac.svn-base 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. if (!dojo._hasResource["dojox.fx.scroll"]) { // _hasResource checks added by
  2. // build. Do not use
  3. // _hasResource directly in your
  4. // code.
  5. dojo._hasResource["dojox.fx.scroll"] = true;
  6. dojo.provide("dojox.fx.scroll");
  7. dojo.experimental("dojox.fx.scroll");
  8. dojo.require("dojox.fx._core");
  9. dojox.fx.smoothScroll = function(/* Object */args) {
  10. // summary: Returns an animation that will smooth-scroll to a node
  11. // (specified in etup())
  12. // description: This implementation support either horizental or
  13. // vertical scroll, as well as
  14. // both. In addition, element in iframe can be scrolled to correctly.
  15. // offset: {x: int, y: int} this will be added to the target position
  16. // duration: Duration of the animation in milliseconds.
  17. // win: a node or window object to scroll
  18. if (!args.target) {
  19. args.target = dojo.coords(args.node, true);
  20. }
  21. var isWindow = dojo[(dojo.isIE ? "isObject" : "isFunction")](args["win"].scrollTo);
  22. var _anim = (isWindow) ? (function(val) {
  23. args.win.scrollTo(val[0], val[1]);
  24. }) : (function(val) {
  25. args.win.scrollLeft = val[0];
  26. args.win.scrollTop = val[1];
  27. });
  28. var anim = new dojo._Animation(dojo.mixin({
  29. beforeBegin : function() {
  30. if (this.curve) {
  31. delete this.curve;
  32. }
  33. var current = isWindow ? dojo._docScroll() : {
  34. x : args.win.scrollLeft,
  35. y : args.win.scrollTop
  36. };
  37. anim.curve = new dojox.fx._Line([current.x, current.y],
  38. [args.target.x, args.target.y]);
  39. },
  40. onAnimate : _anim
  41. }, args));
  42. return anim; // dojo._Animation
  43. };
  44. }