Debian Codegraph @

dojox/fx/scroll.js

raw symbols SCIP
1 define(["dojo/_base/kernel","dojo/_base/lang", "dojo/_base/fx", "dojo/_base/window", "dojox/fx/_base","dojox/fx/_core","dojo/dom-geometry","dojo/_base/sniff"],
2 function (kernel, lang, baseFx, win, fxExt, Line, domGeom, has){
3 kernel.experimental("dojox.fx.scroll");
4 var fx = lang.getObject("dojox.fx",true);
5 fxExt.smoothScroll = function(/* Object */args){
6 // summary:
7 // Returns an animation that will smooth-scroll to a node
8 // description:
9 // This implementation support either horizontal or vertical scroll, as well as
10 // both. In addition, element in iframe can be scrolled to correctly.
11 // args:
12 // - offset: {x: int, y: int} this will be added to the target position
13 // - duration: Duration of the animation in milliseconds.
14 // - win: a node or window object to scroll
15
16 if(!args.target){ args.target = domGeom.position(args.node); }
17
18 var isWindow = args["win"] === win.global,
19 delta = { x: args.target.x, y: args.target.y };
20 if(!isWindow){
21 var winPos = domGeom.position(args.win);
22 delta.x -= winPos.x;
23 delta.y -= winPos.y;
24 }
25 var _anim = (isWindow) ?
26 (function(val){
27 args.win.scrollTo(val[0],val[1]);
28 }) :
29 (function(val){
30 args.win.scrollLeft = val[0];
31 args.win.scrollTop = val[1];
32 });
33 var anim = new baseFx.Animation(lang.mixin({
34 beforeBegin: function(){
35 if(this.curve){ delete this.curve; }
36 var current = isWindow ? dojo._docScroll() : {x: args.win.scrollLeft, y: args.win.scrollTop};
37 anim.curve = new Line([current.x,current.y],[current.x + delta.x, current.y + delta.y]);
38 },
39 onAnimate: _anim
40 },args));
41 return anim; // dojo.Animation
42 };
43 fx.smoothScroll = fxExt.smoothScroll;
44 return fxExt.smoothScroll;
45 });