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

Unified Diff: tools/telemetry/telemetry/page/actions/scroll.js

Issue 945393002: Adding support for diagonal scrolling to telemetry. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Adding telemetry support for diagonal scrolling. Also added a telemetry test to pinchzoom in and th… Created 5 years, 10 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 side-by-side diff with in-line comments
Download patch
Index: tools/telemetry/telemetry/page/actions/scroll.js
diff --git a/tools/telemetry/telemetry/page/actions/scroll.js b/tools/telemetry/telemetry/page/actions/scroll.js
index 77beb678c6c51ff1ef563424a2f9504bdc619cf7..04d2569808a89d2d60c7fb2bdf80b59a4a0cb7d1 100644
--- a/tools/telemetry/telemetry/page/actions/scroll.js
+++ b/tools/telemetry/telemetry/page/actions/scroll.js
@@ -41,43 +41,71 @@
function ScrollAction(opt_callback, opt_distance_func) {
var self = this;
- this.beginMeasuringHook = function() {}
- this.endMeasuringHook = function() {}
+ this.beginMeasuringHook = function() {};
+ this.endMeasuringHook = function() {};
this.callback_ = opt_callback;
this.distance_func_ = opt_distance_func;
}
+ ScrollAction.prototype.getScrollDistanceDown_ = function() {
+ var clientHeight;
+ // clientHeight is "special" for the body element.
+ if (this.element_ == document.body)
+ clientHeight = window.innerHeight;
+ else
+ clientHeight = this.element_.clientHeight;
+
+ return this.element_.scrollHeight -
+ this.element_.scrollTop -
+ clientHeight;
+ };
+
+ ScrollAction.prototype.getScrollDistanceUp_ = function() {
+ return this.element_.scrollTop;
+ };
+
+ ScrollAction.prototype.getScrollDistanceRight_ = function() {
+ var clientWidth;
+ // clientWidth is "special" for the body element.
+ if (this.element_ == document.body)
+ clientWidth = window.innerWidth;
+ else
+ clientWidth = this.element_.clientWidth;
+
+ return this.element_.scrollWidth - this.element_.scrollLeft - clientWidth;
+ };
+
+ ScrollAction.prototype.getScrollDistanceLeft_ = function() {
+ return this.element_.scrollLeft;
+ };
+
ScrollAction.prototype.getScrollDistance_ = function() {
if (this.distance_func_)
return this.distance_func_();
if (this.options_.direction_ == 'down') {
- var clientHeight;
- // clientHeight is "special" for the body element.
- if (this.element_ == document.body)
- clientHeight = window.innerHeight;
- else
- clientHeight = this.element_.clientHeight;
-
- return this.element_.scrollHeight -
- this.element_.scrollTop -
- clientHeight;
+ return this.getScrollDistanceDown_();
} else if (this.options_.direction_ == 'up') {
- return this.element_.scrollTop;
+ return this.getScrollDistanceUp_();
} else if (this.options_.direction_ == 'right') {
- var clientWidth;
- // clientWidth is "special" for the body element.
- if (this.element_ == document.body)
- clientWidth = window.innerWidth;
- else
- clientWidth = this.element_.clientWidth;
-
- return this.element_.scrollWidth - this.element_.scrollLeft - clientWidth;
+ return this.getScrollDistanceRight_();
} else if (this.options_.direction_ == 'left') {
- return this.element_.scrollLeft;
+ return this.getScrollDistanceLeft_();
+ } else if (this.options_.direction_ == 'upleft') {
+ return Math.min(this.getScrollDistanceUp_(),
+ this.getScrollDistanceLeft_());
+ } else if (this.options_.direction_ == 'upright') {
+ return Math.min(this.getScrollDistanceUp_(),
+ this.getScrollDistanceRight_());
+ } else if (this.options_.direction_ == 'downleft') {
+ return Math.min(this.getScrollDistanceDown_(),
+ this.getScrollDistanceLeft_());
+ } else if (this.options_.direction_ == 'downright') {
+ return Math.min(this.getScrollDistanceDown_(),
+ this.getScrollDistanceRight_());
}
- }
+ };
ScrollAction.prototype.start = function(opt_options) {
this.options_ = new ScrollGestureOptions(opt_options);

Powered by Google App Engine
This is Rietveld 408576698