OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // This file provides the ScrollAction object, which scrolls a page | 5 // This file provides the ScrollAction object, which scrolls a page |
6 // to the bottom or for a specified distance: | 6 // to the bottom or for a specified distance: |
7 // 1. var action = new __ScrollAction(callback, opt_distance_func) | 7 // 1. var action = new __ScrollAction(callback, opt_distance_func) |
8 // 2. action.start(scroll_options) | 8 // 2. action.start(scroll_options) |
9 'use strict'; | 9 'use strict'; |
10 | 10 |
11 (function() { | 11 (function() { |
12 var MAX_SCROLL_LENGTH_TIME_MS = 6250; | 12 var MAX_SCROLL_LENGTH_TIME_MS = 6250; |
13 | 13 |
14 function ScrollGestureOptions(opt_options) { | 14 function ScrollGestureOptions(opt_options) { |
15 if (opt_options) { | 15 if (opt_options) { |
16 this.element_ = opt_options.element; | 16 this.element_ = opt_options.element; |
17 this.left_start_ratio_ = opt_options.left_start_ratio; | 17 this.left_start_ratio_ = opt_options.left_start_ratio; |
18 this.top_start_ratio_ = opt_options.top_start_ratio; | 18 this.top_start_ratio_ = opt_options.top_start_ratio; |
19 this.direction_ = opt_options.direction; | 19 this.direction_ = opt_options.direction; |
20 this.speed_ = opt_options.speed; | 20 this.speed_ = opt_options.speed; |
21 this.gesture_source_type_ = opt_options.gesture_source_type; | 21 this.gesture_source_type_ = opt_options.gesture_source_type; |
22 } else { | 22 } else { |
23 this.element_ = document.body; | 23 this.element_ = document.scrollingElement; |
24 this.left_start_ratio_ = 0.5; | 24 this.left_start_ratio_ = 0.5; |
25 this.top_start_ratio_ = 0.5; | 25 this.top_start_ratio_ = 0.5; |
26 this.direction_ = 'down'; | 26 this.direction_ = 'down'; |
27 this.speed_ = 800; | 27 this.speed_ = 800; |
28 this.gesture_source_type_ = chrome.gpuBenchmarking.DEFAULT_INPUT; | 28 this.gesture_source_type_ = chrome.gpuBenchmarking.DEFAULT_INPUT; |
29 } | 29 } |
30 } | 30 } |
31 | 31 |
32 function supportedByBrowser() { | 32 function supportedByBrowser() { |
33 return !!(window.chrome && | 33 return !!(window.chrome && |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
138 this.endMeasuringHook(); | 138 this.endMeasuringHook(); |
139 | 139 |
140 // We're done. | 140 // We're done. |
141 if (this.callback_) | 141 if (this.callback_) |
142 this.callback_(); | 142 this.callback_(); |
143 }; | 143 }; |
144 | 144 |
145 window.__ScrollAction = ScrollAction; | 145 window.__ScrollAction = ScrollAction; |
146 window.__ScrollAction_SupportedByBrowser = supportedByBrowser; | 146 window.__ScrollAction_SupportedByBrowser = supportedByBrowser; |
147 })(); | 147 })(); |
OLD | NEW |