-
Notifications
You must be signed in to change notification settings - Fork 17
/
Copy path_ScrollBarBase.js
131 lines (110 loc) · 2.77 KB
/
_ScrollBarBase.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
define([
"dojo/_base/declare",
"dojo/_base/event",
"dojo/_base/lang",
"dojo/on",
"dojo/dom-style",
"dojo/sniff",
"dijit/_WidgetBase",
"dojox/html/metrics"],
function(
declare,
event,
lang,
on,
domStyle,
has,
_WidgetBase,
metrics){
return declare('dojox.calendar._ScrollBarBase', _WidgetBase, {
// value: Number
// The value of the scroll bar in pixel offset.
value: 0,
// minimum: Number
// The minimum value of the scroll bar.
minimum: 0,
// maximum: Number
// The maximum value of the scroll bar.
maximum: 100,
// direction: String
// Direction of the scroll bar. Valid values are "vertical" or "horizontal".
direction: "vertical",
_vertical: true,
_scrollHandle: null,
containerSize: 0,
buildRendering: function(){
this.inherited(arguments);
this.own(on(this.domNode, "scroll", lang.hitch(this, function(param) {
this.value = this._getDomScrollerValue();
this.onChange(this.value);
this.onScroll(this.value);
})));
},
_getDomScrollerValue : function() {
if(this._vertical){
return this.domNode.scrollTop;
}
var rtl = !this.isLeftToRight();
if(rtl){
if(has("webkit") || has("ie") == 7){
if(this._scW == undefined){
this._scW = metrics.getScrollbar().w;
}
return this.maximum - this.domNode.scrollLeft - this.containerSize + this._scW;
}
if(has("mozilla")){
return -this.domNode.scrollLeft;
}
// ie>7 and others...
}
return this.domNode.scrollLeft;
},
_setDomScrollerValue : function(value) {
this.domNode[this._vertical?"scrollTop":"scrollLeft"] = value;
},
_setValueAttr: function(value){
value = Math.min(this.maximum, value);
value = Math.max(this.minimum, value);
if (this.value != value) {
this.value = value;
this.onChange(value);
this._setDomScrollerValue(value);
}
},
onChange: function(value){
// summary:
// An extension point invoked when the value has changed.
// value: Integer
// The position of the scroll bar in pixels.
// tags:
// callback
},
onScroll: function(value){
// summary:
// An extension point invoked when the user scrolls with the mouse.
// value: Integer
// The position of the scroll bar in pixels.
// tags:
// callback
},
_setMinimumAttr: function(value){
value = Math.min(value, this.maximum);
this.minimum = value;
},
_setMaximumAttr: function(value){
value = Math.max(value, this.minimum);
this.maximum = value;
domStyle.set(this.content, this._vertical?"height":"width", value + "px");
},
_setDirectionAttr: function(value){
if(value == "vertical"){
value = "vertical";
this._vertical = true;
}else{
value = "horizontal";
this._vertical = false;
}
this._set("direction", value);
}
});
});