diff --git a/src/app/ChromeStateTracker.qml b/src/app/ChromeStateTracker.qml index 54e239f67..b7ba904d9 100644 --- a/src/app/ChromeStateTracker.qml +++ b/src/app/ChromeStateTracker.qml @@ -25,16 +25,16 @@ import QtQuick 2.4 ScrollTracker { id: chromeStateTracker - active: webview && !webview.fullscreen + active: webview && !webview.fullscreen && !webview.loading onScrolledUp: { - if (!header.moving && chromeStateChangeTimer.settled) { + if (chromeStateChangeTimer.settled) { delayedAutoHideTimer.up = true delayedAutoHideTimer.restart() } } onScrolledDown: { - if (!header.moving && chromeStateChangeTimer.settled) { + if (chromeStateChangeTimer.settled) { delayedAutoHideTimer.up = false delayedAutoHideTimer.restart() } @@ -69,14 +69,16 @@ ScrollTracker { // See https://bugs.launchpad.net/morph-browser/+bug/1354700. Timer { id: chromeStateChangeTimer - interval: 50 - running: !chromeStateTracker.header.moving + interval: 150 onTriggered: settled = true property bool settled: true } Connections { target: chromeStateTracker.header - onMovingChanged: chromeStateChangeTimer.settled = false + onStateChanged: { + chromeStateChangeTimer.settled = false; + chromeStateChangeTimer.restart(); + } } } diff --git a/src/app/ScrollTracker.qml b/src/app/ScrollTracker.qml index d04fb29c3..8d3d19cfe 100644 --- a/src/app/ScrollTracker.qml +++ b/src/app/ScrollTracker.qml @@ -24,8 +24,8 @@ Item { property var webview property var header - readonly property bool nearTop: webview ? webview.contentY < (internal.headerHeight / internal.contentRatio) : false - readonly property bool nearBottom: webview ? (webview.contentY + internal.viewportHeight + internal.headerHeight / internal.contentRatio) > internal.contentHeight : false + readonly property bool nearTop: webview ? (webview.scrollPosition.y / webview.scaleFactor) < units.gu(4) : false + readonly property bool nearBottom: webview ? ((webview.contentsSize.height - webview.scrollPosition.y) / webview.scaleFactor - webview.height) < units.gu(4) : false property bool active: true @@ -37,29 +37,28 @@ Item { QtObject { id: internal + property real previousScrollPositionY: 0.0 + } - readonly property real headerHeight: scrollTracker.header ? scrollTracker.header.height : 0 - readonly property real headerVisibleHeight: scrollTracker.header ? scrollTracker.header.visibleHeight : 0 + Connections { + target: scrollTracker.active ? scrollTracker.webview : null + onScrollPositionChanged: { - readonly property real contentHeight: scrollTracker.webview ? scrollTracker.webview.contentHeight + headerVisibleHeight : 0.0 - readonly property real viewportHeight: scrollTracker.webview ? scrollTracker.webview.viewportHeight + headerVisibleHeight : 0.0 - readonly property real maxContentY: scrollTracker.webview ? scrollTracker.webview.contentHeight - scrollTracker.webview.viewportHeight : 0.0 + if (header.moving) { + return; + } - readonly property real contentRatio: scrollTracker.webview ? scrollTracker.webview.viewportHeight / scrollTracker.webview.contentHeight : 1.0 + if (scrollTracker.webview.scrollPosition.y === internal.previousScrollPositionY) { + return; + } - readonly property real currentScrollFraction: (maxContentY == 0.0) ? 0.0 : (scrollTracker.webview.contentY / maxContentY) - property real previousScrollFraction: 0.0 - } + var oldScrollPosition = internal.previousScrollPositionY; + internal.previousScrollPositionY = scrollTracker.webview.scrollPosition.y; - Connections { - target: scrollTracker.active ? scrollTracker.webview : null - onContentYChanged: { - var old = internal.previousScrollFraction - internal.previousScrollFraction = internal.currentScrollFraction - if (internal.currentScrollFraction < old) { - scrollTracker.scrolledUp() - } else if (internal.currentScrollFraction > old) { - scrollTracker.scrolledDown() + if (internal.previousScrollPositionY < oldScrollPosition) { + scrollTracker.scrolledUp() + } else if (internal.previousScrollPositionY > oldScrollPosition) { + scrollTracker.scrolledDown() } } } diff --git a/src/app/webbrowser/Browser.qml b/src/app/webbrowser/Browser.qml index a4d2e17f6..833a88c1b 100644 --- a/src/app/webbrowser/Browser.qml +++ b/src/app/webbrowser/Browser.qml @@ -580,7 +580,6 @@ Common.BrowserView { visible: bottomEdgeHandle.dragging || tabslist.animating || (state == "shown") onVisibleChanged: { if (visible) { - currentWebview.hideContextMenu(); chrome.state = "hidden"; }