Browse Source

Merge pull request #39 from servusoft/master

small optimization on typing
Alex Miasoiedov 6 years ago
parent
commit
8f35a55e2a
2 changed files with 6 additions and 3 deletions
  1. 5 2
      static/js/index.js
  2. 1 1
      static/js/save.js

+ 5 - 2
static/js/index.js

@@ -35,13 +35,16 @@ $(function() {
     editor.getSession().setMode("ace/mode/markdown");
     editor.getSession().setUseWrapMode(true);
     editor.setShowPrintMargin(true);
-
     $.get('/slides.md', function(data) {
         editor.setValue(data, -1);
     });
-
+    var lastSRow = -1;
     ace.edit('editor').getSession().selection.on('changeCursor', function(e) {
         var cursorRow = ace.edit('editor').getCursorPosition().row;
+        if(lastSRow === cursorRow){
+          return; // no update
+        }
+        lastSRow = cursorRow;
         var currentSlide = currentCursorSlide(cursorRow);
         $('#slides-frame')[0].contentWindow.postMessage(JSON.stringify({
             method: 'slide',

+ 1 - 1
static/js/save.js

@@ -15,5 +15,5 @@ $(function() {
     });
   };
 
-  $('#editor').keyup($.debounce(window.save, 300));
+  $('#editor').keyup($.debounce(window.save, 600));
 });