Sfoglia il codice sorgente

Scroll to reveal on switches as well

Scott Lahteine 10 anni fa
parent
commit
37c43a7ab3
1 ha cambiato i file con 15 aggiunte e 1 eliminazioni
  1. 15
    1
      Marlin/configurator/js/configurator.js

+ 15
- 1
Marlin/configurator/js/configurator.js Vedi File

399
       this.log(newline, 2);
399
       this.log(newline, 2);
400
 
400
 
401
       $c.text(txt);
401
       $c.text(txt);
402
+
403
+      // Scroll to reveal the define
404
+      this.scrollToDefine(name);
402
     },
405
     },
403
 
406
 
404
     /**
407
     /**
449
 
452
 
450
       $c.text(txt);
453
       $c.text(txt);
451
 
454
 
455
+      // Scroll to reveal the define
456
+      this.scrollToDefine(name);
457
+    },
458
+
459
+    /**
460
+     * Scroll the field to show a define
461
+     */
462
+    scrollToDefine: function(name, always) {
463
+      this.log('scrollToDefine:'+name,4);
464
+      var $elm = $('#'+name), inf = $elm[0].defineInfo, $c = $(inf.field);
465
+
452
       // Scroll to the altered text if it isn't visible
466
       // Scroll to the altered text if it isn't visible
453
       var halfHeight = $c.height()/2, scrollHeight = $c.prop('scrollHeight'),
467
       var halfHeight = $c.height()/2, scrollHeight = $c.prop('scrollHeight'),
454
           textScrollY = inf.lineNum * scrollHeight/(inf.adv ? total_config_adv_lines : total_config_lines) - halfHeight;
468
           textScrollY = inf.lineNum * scrollHeight/(inf.adv ? total_config_adv_lines : total_config_lines) - halfHeight;
458
       else if (textScrollY > scrollHeight)
472
       else if (textScrollY > scrollHeight)
459
         textScrollY = scrollHeight - 1;
473
         textScrollY = scrollHeight - 1;
460
 
474
 
461
-      if (Math.abs($c.prop('scrollTop') - textScrollY) > halfHeight)
475
+      if (always == true || Math.abs($c.prop('scrollTop') - textScrollY) > halfHeight)
462
         $c.animate({ scrollTop: textScrollY < 0 ? 0 : textScrollY });
476
         $c.animate({ scrollTop: textScrollY < 0 ? 0 : textScrollY });
463
 
477
 
464
     },
478
     },

Loading…
Annulla
Salva