Fix issue with false selection detection

`selection.rangeCount` will return 1 when user is typing something in a
form widget. This will consequently trigger unvoluntary scrolling when
the mouse is moved outside of scrollable area. Checking the actual
length of selected text doesn't trigger this behaviour.
This commit is contained in:
Rupert Angermeier 2015-02-18 13:34:36 +01:00
parent b4a51fc454
commit 8290c4f726

View File

@ -10,8 +10,8 @@ var h = require('../../lib/helper')
function bindSelectionHandler(element, i) {
function getRangeNode() {
var selection = window.getSelection ? window.getSelection() :
document.getSlection ? document.getSlection() : {rangeCount: 0};
if (selection.rangeCount === 0) {
document.getSelection ? document.getSelection() : {rangeCount: 0};
if (selection.toString().length === 0) {
return null;
} else {
return selection.getRangeAt(0).commonAncestorContainer;