From 8290c4f7268dbfd879c42fa38ebe1d19ec32269e Mon Sep 17 00:00:00 2001 From: Rupert Angermeier Date: Wed, 18 Feb 2015 13:34:36 +0100 Subject: [PATCH 1/2] 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. --- src/js/plugin/handler/selection.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/js/plugin/handler/selection.js b/src/js/plugin/handler/selection.js index fffc8f4..90c766d 100644 --- a/src/js/plugin/handler/selection.js +++ b/src/js/plugin/handler/selection.js @@ -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; From 42cf8d367976784c366523e2afa748bb3baf34f2 Mon Sep 17 00:00:00 2001 From: Rupert Angermeier Date: Thu, 19 Feb 2015 16:31:27 +0100 Subject: [PATCH 2/2] Adapt fallback for selection Thanks @darthmaim for pointing this out --- src/js/plugin/handler/selection.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/js/plugin/handler/selection.js b/src/js/plugin/handler/selection.js index 90c766d..774d8f0 100644 --- a/src/js/plugin/handler/selection.js +++ b/src/js/plugin/handler/selection.js @@ -10,7 +10,7 @@ var h = require('../../lib/helper') function bindSelectionHandler(element, i) { function getRangeNode() { var selection = window.getSelection ? window.getSelection() : - document.getSelection ? document.getSelection() : {rangeCount: 0}; + document.getSelection ? document.getSelection() : ''; if (selection.toString().length === 0) { return null; } else {