From: Aleksander Ɓukasz Date: Thu, 14 Aug 2014 14:01:04 +0000 (+0200) Subject: editor: canvas arrow key navigation improvements X-Git-Url: https://git.mdrn.pl/fnpeditor.git/commitdiff_plain/457a2c13a27a5fd49bdd5b0162111e3a9220a6ca?ds=inline editor: canvas arrow key navigation improvements --- diff --git a/src/editor/modules/documentCanvas/canvas/keyboard.js b/src/editor/modules/documentCanvas/canvas/keyboard.js index aae19a0..e2479a5 100644 --- a/src/editor/modules/documentCanvas/canvas/keyboard.js +++ b/src/editor/modules/documentCanvas/canvas/keyboard.js @@ -318,6 +318,17 @@ var keyEventHandlers = [ s.canvas.setCurrentElement(s.canvas.getDocumentElement(position.textNode), {caretTo: position.offset}); } } + if(target) { + scrolled = scroll('top', target); + var left = caretRect.left; + if(left > rect.left + rect.width) { + left = rect.left + rect.width; + } else if(left < rect.left ) { + left = rect.left; + } + position = utils.caretPositionFromPoint(left, rect.bottom - 1 - scrolled); + s.canvas.setCurrentElement(s.canvas.getDocumentElement(position.textNode), {caretTo: position.offset}); + } } }, { @@ -347,6 +358,17 @@ var keyEventHandlers = [ s.canvas.setCurrentElement(s.canvas.getDocumentElement(position.textNode), {caretTo: position.offset}); } } + if(target) { + scrolled = scroll('bottom', target); + var left = caretRect.left; + if(left > rect.left + rect.width) { + left = rect.left + rect.width; + } else if(left < rect.left ) { + left = rect.left; + } + position = utils.caretPositionFromPoint(left, rect.top +1 - scrolled); + s.canvas.setCurrentElement(s.canvas.getDocumentElement(position.textNode), {caretTo: position.offset}); + } } }, {