Commit 94b3525b authored by Alexander.Trofimov's avatar Alexander.Trofimov Committed by Alexander.Trofimov

https://developer.mozilla.org/en-US/docs/Web/Reference/Events/wheel

detect available wheel event (проблема со scroll в chrome, т.к. onmousewheel перекрывался подпиской на wheel)

git-svn-id: svn://192.168.3.15/activex/AVS/Sources/TeamlabOffice/trunk/OfficeWeb@55818 954022d7-b5bf-4e40-9824-e11837661b57
parent c3b3276a
...@@ -164,9 +164,13 @@ ...@@ -164,9 +164,13 @@
this.element.addEventListener("dblclick" , function () {return self._onMouseDblClick.apply(self, arguments);} , false); this.element.addEventListener("dblclick" , function () {return self._onMouseDblClick.apply(self, arguments);} , false);
} }
if (this.widget.addEventListener) { if (this.widget.addEventListener) {
this.widget.addEventListener("mousewheel" , function () {return self._onMouseWheel.apply(self, arguments);} , false); // https://developer.mozilla.org/en-US/docs/Web/Reference/Events/wheel
// for Mozilla Firefox (можно делать проверку на window.MouseScrollEvent || window.WheelEvent для FF) // detect available wheel event
this.widget.addEventListener("DOMMouseScroll", function () {return self._onMouseWheel.apply(self, arguments);} , false); var nameWheelEvent = "onwheel" in document.createElement("div") ? "wheel" : // Modern browsers support "wheel"
document.onmousewheel !== undefined ? "mousewheel" : // Webkit and IE support at least "mousewheel"
"DOMMouseScroll"; // let's assume that remaining browsers are older Firefox
this.widget.addEventListener(nameWheelEvent, function () {return self._onMouseWheel.apply(self, arguments);} , false);
} }
// Курсор для графических объектов. Определяем mousedown и mouseup для выделения текста. // Курсор для графических объектов. Определяем mousedown и mouseup для выделения текста.
...@@ -1504,12 +1508,12 @@ ...@@ -1504,12 +1508,12 @@
} }
var delta = 0; var delta = 0;
if (undefined !== event.wheelDelta && 0 !== event.wheelDelta) { if (undefined !== event.wheelDelta && 0 !== event.wheelDelta) {
delta = -1 * event.wheelDelta / 120; delta = -1 * event.wheelDelta / 40;
} else if (undefined != event.detail && 0 !== event.detail) { } else if (undefined != event.detail && 0 !== event.detail) {
// FF // FF
delta = event.detail / 3; delta = event.detail;
} }
delta /= 3;
var self = this; var self = this;
delta *= event.shiftKey ? 1 : this.settings.wheelScrollLines; delta *= event.shiftKey ? 1 : this.settings.wheelScrollLines;
......
...@@ -176,11 +176,11 @@ ...@@ -176,11 +176,11 @@
break; break;
case 38: // Up case 38: // Up
this._onChangeSelection(null !== this.selectElement ? this._onChangeSelection(null !== this.selectElement ?
this.selectElement.previousSibling : this.firstElement); this.selectElement.previousSibling : this.firstElement, -1);
break; break;
case 40: // Down case 40: // Down
this._onChangeSelection(null !== this.selectElement ? this._onChangeSelection(null !== this.selectElement ?
this.selectElement.nextSibling : this.firstElement); this.selectElement.nextSibling : this.firstElement, +1);
break; break;
case 16: // Shift case 16: // Shift
break; break;
...@@ -223,15 +223,21 @@ ...@@ -223,15 +223,21 @@
this._onChangeSelection(event.currentTarget); this._onChangeSelection(event.currentTarget);
}; };
PopUpSelector.prototype._onChangeSelection = function (newElement) { PopUpSelector.prototype._onChangeSelection = function (newElement, scrollDir) {
if (null === newElement) if (null === newElement)
return; return;
if (null !== this.selectElement) var height = 0;
if (null !== this.selectElement) {
height = this.selectElement.offsetHeight;
this.selectElement.className = ""; this.selectElement.className = "";
}
this.selectElement = newElement; this.selectElement = newElement;
this.selectElement.className = "selected"; this.selectElement.className = "selected";
if (scrollDir && height)
this.selectorListJQ.scrollTop(scrollDir * height);
}; };
/* /*
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment