mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 766635 - Don't close tabs on diagonal swipes. r=mfinkle
This commit is contained in:
parent
21979b3db6
commit
cd0059d2fa
@ -47,6 +47,8 @@ public class TabsTray extends LinearLayout
|
||||
private static final int SWIPE_CLOSE_VELOCITY = 5;
|
||||
// Time to animate non-flicked tabs of screen, in milliseconds
|
||||
private static final int MAX_ANIMATION_TIME = 250;
|
||||
// Extra weight given to detecting vertical swipes over horizontal ones
|
||||
private static final float SWIPE_VERTICAL_WEIGHT = 1.5;
|
||||
private static enum DragDirection {
|
||||
UNKNOWN,
|
||||
HORIZONTAL,
|
||||
@ -77,6 +79,11 @@ public class TabsTray extends LinearLayout
|
||||
mListener.onTouchEnd(event);
|
||||
}
|
||||
|
||||
// the simple gesture detector doesn't actually call our methods for every touch event
|
||||
// if we're horizontally scrolling we should always return true to prevent scrolling the list
|
||||
if (mListener.getDirection() == DragDirection.HORIZONTAL)
|
||||
result = true;
|
||||
|
||||
return result;
|
||||
}
|
||||
});
|
||||
@ -312,6 +319,10 @@ public class TabsTray extends LinearLayout
|
||||
mList = v;
|
||||
}
|
||||
|
||||
public DragDirection getDirection() {
|
||||
return dir;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onDown(MotionEvent e) {
|
||||
mView = findViewAt((int)e.getX(), (int)e.getY());
|
||||
@ -367,7 +378,9 @@ public class TabsTray extends LinearLayout
|
||||
}
|
||||
|
||||
if (dir == DragDirection.UNKNOWN) {
|
||||
if (Math.abs(distanceX) > Math.abs(distanceY)) {
|
||||
// check if this scroll is more horizontal than vertical. Weight vertical drags a little higher
|
||||
// by using a multiplier
|
||||
if (Math.abs(distanceX) > Math.abs(distanceY) * SWIPE_VERTICAL_WEIGHT) {
|
||||
dir = DragDirection.HORIZONTAL;
|
||||
} else {
|
||||
dir = DragDirection.VERTICAL;
|
||||
@ -389,7 +402,9 @@ public class TabsTray extends LinearLayout
|
||||
return false;
|
||||
|
||||
// velocityX is in pixels/sec. divide by pixels/inch to compare it with swipe velocity
|
||||
if (Math.abs(velocityX)/GeckoAppShell.getDpi() > SWIPE_CLOSE_VELOCITY) {
|
||||
// also make sure that the swipe is in a mostly horizontal direction
|
||||
if (Math.abs(velocityX) > Math.abs(velocityY * SWIPE_VERTICAL_WEIGHT) &&
|
||||
Math.abs(velocityX)/GeckoAppShell.getDpi() > SWIPE_CLOSE_VELOCITY) {
|
||||
// is this is a swipe, we want to continue the row moving at the swipe velocity
|
||||
float d = (velocityX > 0 ? 1 : -1) * mView.getWidth();
|
||||
// convert the velocity (px/sec) to ms by taking the distance
|
||||
|
Loading…
Reference in New Issue
Block a user