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

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

Issue 2138883002: Fix computation of scroll amount in scroll actions. (Closed) Base URL: https://github.com/catapult-project/catapult.git@master
Patch Set: Address comments 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
« no previous file with comments | « no previous file | telemetry/telemetry/internal/actions/drag.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 DragAction object, which performs drag on a page 5 // This file provides the DragAction object, which performs drag on a page
6 // using given start and end positions: 6 // using given start and end positions:
7 // 1. var action = new __DragAction(callback) 7 // 1. var action = new __DragAction(callback)
8 // 2. action.start(drag_options) 8 // 2. action.start(drag_options)
9 'use strict'; 9 'use strict';
10 10
11 (function() { 11 (function() {
12 function DragGestureOptions(opt_options) { 12 function DragGestureOptions(opt_options) {
13 this.element_ = opt_options.element; 13 this.element_ = opt_options.element;
14 this.left_start_ratio_ = opt_options.left_start_ratio; 14 this.left_start_ratio_ = opt_options.left_start_ratio;
15 this.top_start_ratio_ = opt_options.top_start_ratio; 15 this.top_start_ratio_ = opt_options.top_start_ratio;
16 this.left_end_ratio_ = opt_options.left_end_ratio; 16 this.left_end_ratio_ = opt_options.left_end_ratio;
17 this.top_end_ratio_ = opt_options.top_end_ratio; 17 this.top_end_ratio_ = opt_options.top_end_ratio;
18 this.speed_ = opt_options.speed; 18 this.speed_ = opt_options.speed;
19 this.gesture_source_type_ = opt_options.gesture_source_type; 19 this.gesture_source_type_ = opt_options.gesture_source_type;
20 } 20 }
21 21
22 function supportedByBrowser() { 22 function supportedByBrowser() {
23 return !!(window.chrome && 23 return !!(window.chrome &&
24 chrome.gpuBenchmarking && 24 chrome.gpuBenchmarking &&
25 chrome.gpuBenchmarking.smoothDrag); 25 chrome.gpuBenchmarking.smoothDrag &&
26 chrome.gpuBenchmarking.visualViewportHeight &&
27 chrome.gpuBenchmarking.visualViewportWidth);
26 } 28 }
27 29
28 // This class performs drag action using given start and end positions, 30 // This class performs drag action using given start and end positions,
29 // by a single drag gesture. 31 // by a single drag gesture.
30 function DragAction(opt_callback) { 32 function DragAction(opt_callback) {
31 this.beginMeasuringHook = function() {} 33 this.beginMeasuringHook = function() {};
32 this.endMeasuringHook = function() {} 34 this.endMeasuringHook = function() {};
33 35
34 this.callback_ = opt_callback; 36 this.callback_ = opt_callback;
35 } 37 }
36 38
37 DragAction.prototype.start = function(opt_options) { 39 DragAction.prototype.start = function(opt_options) {
38 this.options_ = new DragGestureOptions(opt_options); 40 this.options_ = new DragGestureOptions(opt_options);
39 requestAnimationFrame(this.startGesture_.bind(this)); 41 requestAnimationFrame(this.startGesture_.bind(this));
40 }; 42 };
41 43
42 DragAction.prototype.startGesture_ = function() { 44 DragAction.prototype.startGesture_ = function() {
(...skipping 18 matching lines...) Expand all
61 this.endMeasuringHook(); 63 this.endMeasuringHook();
62 64
63 // We're done. 65 // We're done.
64 if (this.callback_) 66 if (this.callback_)
65 this.callback_(); 67 this.callback_();
66 }; 68 };
67 69
68 window.__DragAction = DragAction; 70 window.__DragAction = DragAction;
69 window.__DragAction_SupportedByBrowser = supportedByBrowser; 71 window.__DragAction_SupportedByBrowser = supportedByBrowser;
70 })(); 72 })();
OLDNEW
« no previous file with comments | « no previous file | telemetry/telemetry/internal/actions/drag.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698