[gnome-shell] appDisplay: Fix pages getting "stuck" under touch
- From: Jasper St. Pierre <jstpierre src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-shell] appDisplay: Fix pages getting "stuck" under touch
- Date: Mon, 28 Apr 2014 17:30:25 +0000 (UTC)
commit 82ec6c08b8c0b46311687930aa2135119949e40b
Author: Jasper St. Pierre <jstpierre mecheye net>
Date: Sun Apr 27 11:05:10 2014 -0400
appDisplay: Fix pages getting "stuck" under touch
We often call goToPage like:
this.goToPage(this._currentPage - 1);
(or + 1). During panning, these are based on the velocity values
of the gesture action. If we're already on the first or last page
and the panning ends, it's possible to get goToPage that's either
-1 or greater than the last page.
During normal usage, this isn't a problem, since the Y values will
be correct, always. But when panning, the Y values stick to the
finger, and thus if we return early, we won't snap to the exact page,
making it seem like things get "stuck".
Fix this the simple way by clamping to the correctly-ranged values
of pageNumber
https://bugzilla.gnome.org/show_bug.cgi?id=729064
js/ui/appDisplay.js | 8 ++++++--
1 files changed, 6 insertions(+), 2 deletions(-)
---
diff --git a/js/ui/appDisplay.js b/js/ui/appDisplay.js
index 2596929..0f5baf8 100644
--- a/js/ui/appDisplay.js
+++ b/js/ui/appDisplay.js
@@ -81,6 +81,10 @@ function _getFolderName(folder) {
return name;
}
+function clamp(value, min, max) {
+ return Math.max(min, Math.min(max, value));
+}
+
const BaseAppView = new Lang.Class({
Name: 'BaseAppView',
Abstract: true,
@@ -439,8 +443,8 @@ const AllView = new Lang.Class({
},
goToPage: function(pageNumber) {
- if(pageNumber < 0 || pageNumber > this._grid.nPages() - 1)
- return;
+ pageNumber = clamp(pageNumber, 0, this._grid.nPages() - 1);
+
if (this._currentPage == pageNumber && this._displayingPopup && this._currentPopup)
return;
if (this._displayingPopup && this._currentPopup)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]