From 4c9597e27b2dabe27a77c71116f1e71f5721ca41 Mon Sep 17 00:00:00 2001 From: "Alex A. Naanou" Date: Mon, 23 Oct 2023 19:38:06 +0300 Subject: [PATCH] added overtravel pauses + cleanup... Signed-off-by: Alex A. Naanou --- experiments/outline-editor/editor.js | 38 +++++++++++++++++++++++++++ experiments/outline-editor/index.html | 27 ++++++++++--------- 2 files changed, 53 insertions(+), 12 deletions(-) diff --git a/experiments/outline-editor/editor.js b/experiments/outline-editor/editor.js index 7f9f71b..6e8d743 100755 --- a/experiments/outline-editor/editor.js +++ b/experiments/outline-editor/editor.js @@ -1390,6 +1390,7 @@ var Outline = { // XXX move the code here into methods/actions... // XXX use keyboard.js... + __overtravel_timeout: undefined, keyboard: { // vertical navigation... // XXX this is a bit hacky but it works -- the caret blinks at @@ -1397,6 +1398,18 @@ var Outline = { // nice po prevent this... ArrowUp: function(evt){ var that = this + + // overtravel... + var overtravel = + this.__overtravel_timeout != null + && this.get() === this.get(0) + this.__overtravel_timeout != null + && clearTimeout(this.__overtravel_timeout) + this.__overtravel_timeout = setTimeout(function(){ + that.__overtravel_timeout = undefined }, 100) + if(overtravel){ + return } + var edited = this.get('edited') if(edited){ var line = edited.getTextGeometry().line @@ -1408,6 +1421,18 @@ var Outline = { this.focus('focused', -1) } }, ArrowDown: function(evt){ var that = this + + // overtravel... + var overtravel = + this.__overtravel_timeout != null + && this.get() === this.get(-1) + this.__overtravel_timeout != null + && clearTimeout(this.__overtravel_timeout) + this.__overtravel_timeout = setTimeout(function(){ + that.__overtravel_timeout = undefined }, 100) + if(overtravel){ + return } + var edited = this.get('edited') if(edited){ var {line, lines} = edited.getTextGeometry() @@ -1441,6 +1466,19 @@ var Outline = { this.toggleCollapse(true) : this.focus('parent') }, ArrowRight: function(evt){ + var that = this + + // overtravel... + var overtravel = + this.__overtravel_timeout != null + && this.get() === this.get(-1) + this.__overtravel_timeout != null + && clearTimeout(this.__overtravel_timeout) + this.__overtravel_timeout = setTimeout(function(){ + that.__overtravel_timeout = undefined }, 100) + if(overtravel){ + return } + var edited = this.get('edited') if(edited){ // move caret to next element... diff --git a/experiments/outline-editor/index.html b/experiments/outline-editor/index.html index 7503d58..6cf3247 100755 --- a/experiments/outline-editor/index.html +++ b/experiments/outline-editor/index.html @@ -51,15 +51,6 @@ var setup = function(){ - - ## ToDo: - crop: show crop path (and depth) - - identify a block: - - DONE index (flat) - - DONE path (index) - - id - - _the id attr is done, but we still need to get the node via id_ - - focus: - - DONE `.autofocus` - - DONE `focused:: true` attr (`.text(..)`/`.json(..)`/`.load(..)`) - - focusing editor -> focus focused block - undo collapsed:: true - edit stack (position, action, ...) @@ -88,9 +79,9 @@ var setup = function(){ - Nerd fonts (option???) - multiple node selection - smooth scrolling - - _...this is more complicated that adding `behavior: "smooth"` to `.scrollIntoView(..)` as scrolling animation will get interrupted by next user input..._ - - need to cancel animation of things are moving too fast... - - make this generic + - _...this is more complicated than adding `behavior: "smooth"` to `.scrollIntoView(..)` as scrolling animation will get interrupted by next user input..._ + - need to cancel animation if things are moving too fast... + - make this generic (???) - FEATURE? block templates... collapsed:: true - something like: `TPL: [_] -- ` @@ -118,6 +109,18 @@ var setup = function(){ block text - NOTE: this is only a problem if making list-items manually -- disable??? - empty item height is a bit off... + - DONE over-travel pause -- when going fast over start/end stop... + - DONE focus: + collapsed:: true + - DONE `.autofocus` + - DONE `focused:: true` attr (`.text(..)`/`.json(..)`/`.load(..)`) + - DONE focusing editor -> focus focused block + - DONE identify a block: + collapsed:: true + - DONE index (flat) + - DONE path (index) + - DONE id + - _the id attr is done, but we still need to get the node via id_ - DONE pgup/pgdown/home/end buttons - DONE FEATURE: "crop" -- view block tree separately... - DONE unify attr parsing