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 @@
this.element.addEventListener("dblclick" , function () {return self._onMouseDblClick.apply(self, arguments);} , false);
}
if (this.widget.addEventListener) {
this.widget.addEventListener("mousewheel" , function () {return self._onMouseWheel.apply(self, arguments);} , false);
// for Mozilla Firefox (можно делать проверку на window.MouseScrollEvent || window.WheelEvent для FF)
this.widget.addEventListener("DOMMouseScroll", function () {return self._onMouseWheel.apply(self, arguments);} , false);
// https://developer.mozilla.org/en-US/docs/Web/Reference/Events/wheel
// detect available wheel event
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 для выделения текста.
......@@ -1504,12 +1508,12 @@
}
var delta = 0;
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) {
// FF
delta = event.detail / 3;
delta = event.detail;
}
delta /= 3;
var self = this;
delta *= event.shiftKey ? 1 : this.settings.wheelScrollLines;
......
......@@ -176,11 +176,11 @@
break;
case 38: // Up
this._onChangeSelection(null !== this.selectElement ?
this.selectElement.previousSibling : this.firstElement);
this.selectElement.previousSibling : this.firstElement, -1);
break;
case 40: // Down
this._onChangeSelection(null !== this.selectElement ?
this.selectElement.nextSibling : this.firstElement);
this.selectElement.nextSibling : this.firstElement, +1);
break;
case 16: // Shift
break;
......@@ -223,15 +223,21 @@
this._onChangeSelection(event.currentTarget);
};
PopUpSelector.prototype._onChangeSelection = function (newElement) {
PopUpSelector.prototype._onChangeSelection = function (newElement, scrollDir) {
if (null === newElement)
return;
if (null !== this.selectElement)
var height = 0;
if (null !== this.selectElement) {
height = this.selectElement.offsetHeight;
this.selectElement.className = "";
}
this.selectElement = newElement;
this.selectElement.className = "selected";
if (scrollDir && height)
this.selectorListJQ.scrollTop(scrollDir * height);
};
/*
......@@ -240,4 +246,4 @@
*/
window["Asc"].PopUpSelector = PopUpSelector;
}
)(jQuery, window);
)(jQuery, window);
\ No newline at end of file
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