Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(214)

Side by Side Diff: telemetry/telemetry/internal/actions/swipe.js

Issue 2162963002: [polymer] Merge of master into polymer10-migration (Closed) Base URL: git@github.com:catapult-project/catapult.git@polymer10-migration
Patch Set: Merge polymer10-migration int polymer10-merge Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 SwipeGestureOptions(opt_options) { 8 function SwipeGestureOptions(opt_options) {
9 if (opt_options) { 9 if (opt_options) {
10 this.element_ = opt_options.element; 10 this.element_ = opt_options.element;
11 this.left_start_ratio_ = opt_options.left_start_ratio; 11 this.left_start_ratio_ = opt_options.left_start_ratio;
12 this.top_start_ratio_ = opt_options.top_start_ratio; 12 this.top_start_ratio_ = opt_options.top_start_ratio;
13 this.direction_ = opt_options.direction; 13 this.direction_ = opt_options.direction;
14 this.distance_ = opt_options.distance; 14 this.distance_ = opt_options.distance;
15 this.speed_ = opt_options.speed; 15 this.speed_ = opt_options.speed;
16 } else { 16 } else {
17 this.element_ = document.body; 17 this.element_ = document.body;
18 this.left_start_ratio_ = 0.5; 18 this.left_start_ratio_ = 0.5;
19 this.top_start_ratio_ = 0.5; 19 this.top_start_ratio_ = 0.5;
20 this.direction_ = 'left'; 20 this.direction_ = 'left';
21 this.distance_ = 0; 21 this.distance_ = 0;
22 this.speed_ = 800; 22 this.speed_ = 800;
23 } 23 }
24 } 24 }
25 25
26 function supportedByBrowser() { 26 function supportedByBrowser() {
27 return !!(window.chrome && 27 return !!(window.chrome &&
28 chrome.gpuBenchmarking && 28 chrome.gpuBenchmarking &&
29 chrome.gpuBenchmarking.swipe); 29 chrome.gpuBenchmarking.swipe &&
30 chrome.gpuBenchmarking.visualViewportHeight &&
31 chrome.gpuBenchmarking.visualViewportWidth);
30 } 32 }
31 33
32 // This class swipes a page for a specified distance. 34 // This class swipes a page for a specified distance.
33 function SwipeAction(opt_callback) { 35 function SwipeAction(opt_callback) {
34 var self = this; 36 var self = this;
35 37
36 this.beginMeasuringHook = function() {} 38 this.beginMeasuringHook = function() {};
37 this.endMeasuringHook = function() {} 39 this.endMeasuringHook = function() {};
38 40
39 this.callback_ = opt_callback; 41 this.callback_ = opt_callback;
40 } 42 }
41 43
42 SwipeAction.prototype.start = function(opt_options) { 44 SwipeAction.prototype.start = function(opt_options) {
43 this.options_ = new SwipeGestureOptions(opt_options); 45 this.options_ = new SwipeGestureOptions(opt_options);
44 // Assign this.element_ here instead of constructor, because the constructor 46 // Assign this.element_ here instead of constructor, because the constructor
45 // ensures this method will be called after the document is loaded. 47 // ensures this method will be called after the document is loaded.
46 this.element_ = this.options_.element_; 48 this.element_ = this.options_.element_;
47 requestAnimationFrame(this.startGesture_.bind(this)); 49 requestAnimationFrame(this.startGesture_.bind(this));
(...skipping 18 matching lines...) Expand all
66 this.endMeasuringHook(); 68 this.endMeasuringHook();
67 69
68 // We're done. 70 // We're done.
69 if (this.callback_) 71 if (this.callback_)
70 this.callback_(); 72 this.callback_();
71 }; 73 };
72 74
73 window.__SwipeAction = SwipeAction; 75 window.__SwipeAction = SwipeAction;
74 window.__SwipeAction_SupportedByBrowser = supportedByBrowser; 76 window.__SwipeAction_SupportedByBrowser = supportedByBrowser;
75 })(); 77 })();
OLDNEW
« no previous file with comments | « telemetry/telemetry/internal/actions/seek.py ('k') | telemetry/telemetry/internal/actions/swipe.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698