appDisplay: Make page panning smoother on touch
Currently, our logic for page panning isn't great. If the user starts a pan upwards and hesitates over a new page, we'll go to the *next* page on release, since the difference is greater, but the velocity wound down to 0. Instead of trying to treat it like page down or scrolls, simply do the math to find the page where the user scrolled to. This is unfortunately broken for fast swipes, since the user doesn't get far enough into the new page to make a difference. I'm getting the impression we'll need a gesture recognizer for this, though, however crude. Simple hacks I tried, like a velocity multiplier, didn't work properly. https://bugzilla.gnome.org/show_bug.cgi?id=729064
This commit is contained in:
parent
82ec6c08b8
commit
28c1f81f4a
@ -41,9 +41,7 @@ const MIN_FREQUENT_APPS_COUNT = 3;
|
||||
const INDICATORS_BASE_TIME = 0.25;
|
||||
const INDICATORS_ANIMATION_DELAY = 0.125;
|
||||
const INDICATORS_ANIMATION_MAX_TIME = 0.75;
|
||||
// Fraction of page height the finger or mouse must reach
|
||||
// to change page
|
||||
const PAGE_SWITCH_TRESHOLD = 0.2;
|
||||
|
||||
const PAGE_SWITCH_TIME = 0.3;
|
||||
|
||||
const VIEWS_SWITCH_TIME = 0.4;
|
||||
@ -528,15 +526,19 @@ const AllView = new Lang.Class({
|
||||
_onPanEnd: function(action) {
|
||||
if (this._displayingPopup)
|
||||
return;
|
||||
let diffCurrentPage = this._diffToPage(this._currentPage);
|
||||
if (diffCurrentPage > this._scrollView.height * PAGE_SWITCH_TRESHOLD) {
|
||||
if (action.get_velocity(0)[2] > 0)
|
||||
this.goToPage(this._currentPage - 1);
|
||||
else
|
||||
this.goToPage(this._currentPage + 1);
|
||||
} else {
|
||||
this.goToPage(this._currentPage);
|
||||
}
|
||||
|
||||
let pageHeight = this._grid.getPageHeight();
|
||||
|
||||
// Calculate the scroll value we'd be at, which is our current
|
||||
// scroll plus any velocity the user had when they released
|
||||
// their finger.
|
||||
|
||||
let velocity = -action.get_velocity(0)[2];
|
||||
let endPanValue = this._adjustment.value + velocity;
|
||||
|
||||
let closestPage = Math.round(endPanValue / pageHeight);
|
||||
this.goToPage(closestPage);
|
||||
|
||||
this._panning = false;
|
||||
},
|
||||
|
||||
|
@ -645,6 +645,10 @@ const PaginatedIconGrid = new Lang.Class({
|
||||
return this._nPages;
|
||||
},
|
||||
|
||||
getPageHeight: function() {
|
||||
return this._availableHeightPerPageForItems();
|
||||
},
|
||||
|
||||
getPageY: function(pageNumber) {
|
||||
if (!this._nPages)
|
||||
return 0;
|
||||
|
Loading…
Reference in New Issue
Block a user