michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: document.getAnonymousElementByAttribute(this, "anonid", "scrollbox"); michael@0: michael@0: michael@0: document.getAnonymousElementByAttribute(this, "anonid", "scrollbutton-up"); michael@0: michael@0: michael@0: document.getAnonymousElementByAttribute(this, "anonid", "scrollbutton-down"); michael@0: michael@0: michael@0: null michael@0: michael@0: michael@0: michael@0: michael@0: null michael@0: michael@0: michael@0: michael@0: michael@0: null michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: null michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: null michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: = (vertical ? scrollContentRect.bottom : scrollContentRect.right)) { michael@0: elementEnd = vertical ? scrollPaddingRect.bottom : scrollPaddingRect.right; michael@0: } michael@0: michael@0: var amountToScroll; michael@0: michael@0: if (elementStart < containerStart) { michael@0: amountToScroll = elementStart - containerStart; michael@0: } else if (containerEnd < elementEnd) { michael@0: amountToScroll = elementEnd - containerEnd; michael@0: } else if (this._isScrolling) { michael@0: // decelerate if a currently-visible element is selected during the scroll michael@0: const STOP_DISTANCE = 15; michael@0: if (this._isScrolling == -1 && elementStart - STOP_DISTANCE < containerStart) michael@0: amountToScroll = elementStart - containerStart; michael@0: else if (this._isScrolling == 1 && containerEnd - STOP_DISTANCE < elementEnd) michael@0: amountToScroll = elementEnd - containerEnd; michael@0: else michael@0: amountToScroll = this._isScrolling * STOP_DISTANCE; michael@0: } else { michael@0: return; michael@0: } michael@0: michael@0: this._stopSmoothScroll(); michael@0: michael@0: if (aSmoothScroll != false && this.smoothScroll) { michael@0: this._smoothScrollByPixels(amountToScroll, element); michael@0: } else { michael@0: this.scrollByPixels(amountToScroll); michael@0: } michael@0: ]]> michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: = this.duration ? 1 : michael@0: 1 - Math.pow(1 - timePassed / this.duration, 4); michael@0: michael@0: this.scrollbox.scrollPosition = this.startPos + (this.distance * pos); michael@0: michael@0: if (pos == 1) michael@0: this.scrollbox._stopSmoothScroll(); michael@0: else michael@0: this.requestHandle = window.mozRequestAnimationFrame(this); michael@0: } michael@0: })]]> michael@0: michael@0: michael@0: michael@0: michael@0: 0 ? rect[end] + 1 : rect[start] - 1; michael@0: var nextElement = this._elementFromPoint(x, index); michael@0: if (!nextElement) michael@0: return; michael@0: michael@0: var targetElement; michael@0: if (this._isRTLScrollbox) michael@0: index *= -1; michael@0: while (index < 0 && nextElement) { michael@0: if (this._canScrollToElement(nextElement)) michael@0: targetElement = nextElement; michael@0: nextElement = nextElement.previousSibling; michael@0: index++; michael@0: } michael@0: while (index > 0 && nextElement) { michael@0: if (this._canScrollToElement(nextElement)) michael@0: targetElement = nextElement; michael@0: nextElement = nextElement.nextSibling; michael@0: index--; michael@0: } michael@0: if (!targetElement) michael@0: return; michael@0: michael@0: this.ensureElementIsVisible(targetElement, aSmoothScroll); michael@0: ]]> michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: elements[high].getBoundingClientRect()[end]) michael@0: return null; michael@0: michael@0: var mid, rect; michael@0: while (low <= high) { michael@0: mid = Math.floor((low + high) / 2); michael@0: rect = elements[mid].getBoundingClientRect(); michael@0: if (rect[start] > aX) michael@0: high = mid - 1; michael@0: else if (rect[end] < aX) michael@0: low = mid + 1; michael@0: else michael@0: return elements[mid]; michael@0: } michael@0: michael@0: // There's no element at the requested coordinate, but the algorithm michael@0: // from above yields an element next to it, in a random direction. michael@0: // The desired scrolling direction leads to the correct element. michael@0: michael@0: if (!aPhysicalScrollDir) michael@0: return null; michael@0: michael@0: if (aPhysicalScrollDir < 0 && rect[start] > aX) michael@0: mid = Math.max(mid - 1, 0); michael@0: else if (aPhysicalScrollDir > 0 && rect[end] < aX) michael@0: mid = Math.min(mid + 1, elements.length - 1); michael@0: michael@0: return elements[mid]; michael@0: ]]> michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: 0 michael@0: [null, null] michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: 1) michael@0: this._prevMouseScrolls.shift(); michael@0: this._prevMouseScrolls.push(isVertical); michael@0: } michael@0: michael@0: event.stopPropagation(); michael@0: event.preventDefault(); michael@0: ]]> michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: 0 michael@0: 150 michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: 3) michael@0: return; michael@0: michael@0: var scrollBack = (aEvent.originalTarget == this._scrollButtonUp); michael@0: var scrollLeftOrUp = this._isRTLScrollbox ? !scrollBack : scrollBack; michael@0: var targetElement; michael@0: michael@0: if (aEvent.detail == 2) { michael@0: // scroll by the size of the scrollbox michael@0: let [start, end] = this._startEndProps; michael@0: let x; michael@0: if (scrollLeftOrUp) michael@0: x = this.scrollClientRect[start] - this.scrollClientSize; michael@0: else michael@0: x = this.scrollClientRect[end] + this.scrollClientSize; michael@0: targetElement = this._elementFromPoint(x, scrollLeftOrUp ? -1 : 1); michael@0: michael@0: // the next partly-hidden element will become fully visible, michael@0: // so don't scroll too far michael@0: if (targetElement) michael@0: targetElement = scrollBack ? michael@0: targetElement.nextSibling : michael@0: targetElement.previousSibling; michael@0: } michael@0: michael@0: if (!targetElement) { michael@0: // scroll to the first resp. last element michael@0: let elements = this._getScrollableElements(); michael@0: targetElement = scrollBack ? michael@0: elements[0] : michael@0: elements[elements.length - 1]; michael@0: } michael@0: michael@0: this.ensureElementIsVisible(targetElement); michael@0: ]]> michael@0: michael@0: michael@0: michael@0: michael@0: