зеркало из https://github.com/mozilla/gecko-dev.git
Bug 807990 - Scroll reader mode page by one page on double tap. r=lucasr,cwiiis
This commit is contained in:
Родитель
74a3c90903
Коммит
c817ca3e77
|
@ -1373,9 +1373,7 @@ class JavaPanZoomController
|
|||
|
||||
@Override
|
||||
public boolean onDoubleTap(MotionEvent motionEvent) {
|
||||
if (mTarget.getZoomConstraints().getAllowDoubleTapZoom()) {
|
||||
sendPointToGecko("Gesture:DoubleTap", motionEvent);
|
||||
}
|
||||
sendPointToGecko("Gesture:DoubleTap", motionEvent);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -35,6 +35,7 @@ let AboutReader = function(doc, win) {
|
|||
Services.obs.addObserver(this, "Reader:Add", false);
|
||||
Services.obs.addObserver(this, "Reader:Remove", false);
|
||||
Services.obs.addObserver(this, "Reader:ListStatusReturn", false);
|
||||
Services.obs.addObserver(this, "Gesture:DoubleTap", false);
|
||||
|
||||
this._article = null;
|
||||
|
||||
|
@ -223,6 +224,19 @@ AboutReader.prototype = {
|
|||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case "Gesture:DoubleTap": {
|
||||
let args = JSON.parse(aData);
|
||||
let scrollBy;
|
||||
// Arbitary choice of innerHeight - 50 to give some context after scroll
|
||||
if (args.y < (this._win.innerHeight / 2)) {
|
||||
scrollBy = -this._win.innerHeight + 50;
|
||||
} else {
|
||||
scrollBy = this._win.innerHeight - 50;
|
||||
}
|
||||
this._scrollPage(scrollBy);
|
||||
break;
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
|
@ -261,10 +275,21 @@ AboutReader.prototype = {
|
|||
Services.obs.removeObserver(this, "Reader:Add");
|
||||
Services.obs.removeObserver(this, "Reader:Remove");
|
||||
Services.obs.removeObserver(this, "Reader:ListStatusReturn");
|
||||
Services.obs.removeObserver(this, "Gesture:DoubleTap");
|
||||
break;
|
||||
}
|
||||
},
|
||||
|
||||
_scrollPage: function Reader_scrollPage(scrollByPixels) {
|
||||
let viewport = BrowserApp.selectedTab.getViewport();
|
||||
let newY = Math.min(Math.max(viewport.cssY + scrollByPixels, viewport.cssPageTop), viewport.cssPageBottom);
|
||||
let newRect = new Rect(viewport.cssX, newY, viewport.cssWidth, viewport.cssHeight);
|
||||
|
||||
this._setToolbarVisibility(false);
|
||||
this._scrolled = true;
|
||||
ZoomHelper.zoomToRect(newRect, -1, false, false);
|
||||
},
|
||||
|
||||
_updateToggleButton: function Reader_updateToggleButton() {
|
||||
let classes = this._doc.getElementById("toggle-button").classList;
|
||||
|
||||
|
|
|
@ -4878,6 +4878,11 @@ var BrowserEventHandler = {
|
|||
},
|
||||
|
||||
onDoubleTap: function(aData) {
|
||||
let metadata = BrowserApp.selectedTab.metadata;
|
||||
if (!metadata.allowDoubleTapZoom) {
|
||||
return;
|
||||
}
|
||||
|
||||
let data = JSON.parse(aData);
|
||||
let element = ElementTouchHelper.anyElementFromPoint(data.x, data.y);
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче