зеркало из https://github.com/mozilla/gecko-dev.git
Bug 565783: Eliminate bounce when scrolling tab bar. r=enndeakin,dolske
This commit is contained in:
Родитель
2ac461c8a4
Коммит
472a2979e7
|
@ -64,8 +64,12 @@ function runOverflowTests(aEvent) {
|
|||
EventUtils.synthesizeMouse(upButton, 0, 0, {clickCount: 3});
|
||||
isLeft(tabContainer.firstChild, "Scrolled to the start with a triple click");
|
||||
|
||||
for (var i = 2; i; i--)
|
||||
EventUtils.synthesizeMouseScroll(scrollbox, 0, 0, {axis: "horizontal", delta: -1});
|
||||
isLeft(tabContainer.firstChild, "Remained at the start with the mouse wheel");
|
||||
|
||||
element = nextRightElement();
|
||||
EventUtils.synthesizeMouseScroll(scrollbox, 0, 0, {delta: 1});
|
||||
EventUtils.synthesizeMouseScroll(scrollbox, 0, 0, {axis: "horizontal", delta: 1});
|
||||
isRight(element, "Scrolled one tab to the right with the mouse wheel");
|
||||
|
||||
while (tabContainer.childNodes.length > 1)
|
||||
|
|
|
@ -183,6 +183,7 @@ function testArrowScrollbox(id)
|
|||
var pos = orient == "horizontal" ? xpos : ypos;
|
||||
|
||||
scrollBoxObject.scrollTo(aStart, aStart);
|
||||
for (var i = (orient == "horizontal") ? 2 : 0; i >= 0; i--) {
|
||||
synthesizeMouseScroll(scrollbox, 5, 5,
|
||||
{axis:"vertical", delta:aDelta, type:aKind.eventType,
|
||||
hasPixels:aKind.hasPixels});
|
||||
|
@ -190,10 +191,13 @@ function testArrowScrollbox(id)
|
|||
// Note, vertical mouse scrolling is allowed to scroll horizontal
|
||||
// arrowscrollboxes, because many users have no horizontal mouse scroll
|
||||
// capability
|
||||
is(pos.value, aKind.shouldScrollDOM ? aExpected : aStart,
|
||||
var expected = (aKind.shouldScrollDOM && !i) ? aExpected : aStart;
|
||||
is(pos.value, expected,
|
||||
"mouse-scroll of '" + id + "' vertical starting " + aStart + " delta " + aDelta
|
||||
+ " eventType " + aKind.eventType + " hasPixels " + aKind.hasPixels);
|
||||
}
|
||||
|
||||
for (var i = (orient == "horizontal") ? 2 : 0; i >= 0; i--) {
|
||||
scrollBoxObject.scrollTo(aStart, aStart);
|
||||
synthesizeMouseScroll(scrollbox, 5, 5,
|
||||
{axis:"horizontal", delta:aDelta, type:aKind.eventType,
|
||||
|
@ -201,11 +205,12 @@ function testArrowScrollbox(id)
|
|||
// horizontal mouse scrolling is never allowed to scroll vertical
|
||||
// arrowscrollboxes
|
||||
scrollBoxObject.getPosition(xpos, ypos);
|
||||
var expected = (aKind.shouldScrollDOM && (orient == "horizontal")) ? aExpected : aStart;
|
||||
var expected = (aKind.shouldScrollDOM && !i && (orient == "horizontal")) ? aExpected : aStart;
|
||||
is(pos.value, expected,
|
||||
"mouse-scroll of '" + id + "' horizontal starting " + aStart + " delta " + aDelta
|
||||
+ " eventType " + aKind.eventType + " hasPixels " + aKind.hasPixels);
|
||||
}
|
||||
}
|
||||
|
||||
var scrolledWidth = {};
|
||||
var scrolledHeight = {};
|
||||
|
|
|
@ -381,6 +381,7 @@
|
|||
-1: scrolling left -->
|
||||
<field name="_isScrolling">0</field>
|
||||
<field name="_smoothScrollTimer">0</field>
|
||||
<field name="_prevMouseScrolls">[null, null]</field>
|
||||
|
||||
<method name="_stopSmoothScroll">
|
||||
<body><![CDATA[
|
||||
|
@ -422,15 +423,30 @@
|
|||
|
||||
<handlers>
|
||||
<handler event="DOMMouseScroll"><![CDATA[
|
||||
if (this.orient == "vertical") {
|
||||
// prevent horizontal scrolling from scrolling a vertical scrollbox
|
||||
if (event.axis == event.HORIZONTAL_AXIS &&
|
||||
this.orient == "vertical")
|
||||
if (event.axis == event.HORIZONTAL_AXIS)
|
||||
return;
|
||||
this.scrollByIndex(event.detail);
|
||||
}
|
||||
// We allow vertical scrolling to scroll a horizontal scrollbox
|
||||
// because many users have a vertical scroll wheel but no
|
||||
// horizontal support.
|
||||
// Because of this, we need to avoid scrolling chaos on trackpads
|
||||
// and mouse wheels that support simultaneous scrolling in both axes.
|
||||
// We do this by scrolling only when the last two scroll events were
|
||||
// on the same axis as the current scroll event.
|
||||
else {
|
||||
let isVertical = event.axis == event.VERTICAL_AXIS;
|
||||
|
||||
if (this._prevMouseScrolls.every(function(prev) prev == isVertical))
|
||||
this.scrollByIndex(event.detail);
|
||||
|
||||
if (this._prevMouseScrolls.length > 1)
|
||||
this._prevMouseScrolls.shift();
|
||||
this._prevMouseScrolls.push(isVertical);
|
||||
}
|
||||
|
||||
event.stopPropagation();
|
||||
]]></handler>
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче