OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 'use strict'; | 5 'use strict'; |
6 | 6 |
7 (function() { | 7 (function() { |
8 function supportedByBrowser() { | 8 function supportedByBrowser() { |
9 return !!(window.chrome && | 9 return !!(window.chrome && |
10 chrome.gpuBenchmarking && | 10 chrome.gpuBenchmarking && |
11 chrome.gpuBenchmarking.scrollBounce); | 11 chrome.gpuBenchmarking.scrollBounce && |
| 12 chrome.gpuBenchmarking.visualViewportHeight && |
| 13 chrome.gpuBenchmarking.visualViewportWidth); |
12 } | 14 } |
13 | 15 |
14 function ScrollBounceAction(opt_callback) { | 16 function ScrollBounceAction(opt_callback) { |
15 var self = this; | 17 var self = this; |
16 | 18 |
17 this.beginMeasuringHook = function() {} | 19 this.beginMeasuringHook = function() {}; |
18 this.endMeasuringHook = function() {} | 20 this.endMeasuringHook = function() {}; |
19 | 21 |
20 this.callback_ = opt_callback; | 22 this.callback_ = opt_callback; |
21 } | 23 } |
22 | 24 |
23 ScrollBounceAction.prototype.start = function(options) { | 25 ScrollBounceAction.prototype.start = function(options) { |
24 this.options_ = options; | 26 this.options_ = options; |
25 // Assign this.element_ here instead of constructor, because the constructor | 27 // Assign this.element_ here instead of constructor, because the constructor |
26 // ensures this method will be called after the document is loaded. | 28 // ensures this method will be called after the document is loaded. |
27 this.element_ = this.options_.element; | 29 this.element_ = this.options_.element; |
28 requestAnimationFrame(this.startGesture_.bind(this)); | 30 requestAnimationFrame(this.startGesture_.bind(this)); |
(...skipping 20 matching lines...) Expand all Loading... |
49 this.endMeasuringHook(); | 51 this.endMeasuringHook(); |
50 | 52 |
51 // We're done. | 53 // We're done. |
52 if (this.callback_) | 54 if (this.callback_) |
53 this.callback_(); | 55 this.callback_(); |
54 }; | 56 }; |
55 | 57 |
56 window.__ScrollBounceAction = ScrollBounceAction; | 58 window.__ScrollBounceAction = ScrollBounceAction; |
57 window.__ScrollBounceAction_SupportedByBrowser = supportedByBrowser; | 59 window.__ScrollBounceAction_SupportedByBrowser = supportedByBrowser; |
58 })(); | 60 })(); |
OLD | NEW |