ソースを参照

Scroll to reveal on switches as well

Scott Lahteine 10年前
コミット
37c43a7ab3
1個のファイルの変更15行の追加1行の削除
  1. 15
    1
      Marlin/configurator/js/configurator.js

+ 15
- 1
Marlin/configurator/js/configurator.js ファイルの表示

@@ -399,6 +399,9 @@ var configuratorApp = (function(){
399 399
       this.log(newline, 2);
400 400
 
401 401
       $c.text(txt);
402
+
403
+      // Scroll to reveal the define
404
+      this.scrollToDefine(name);
402 405
     },
403 406
 
404 407
     /**
@@ -449,6 +452,17 @@ var configuratorApp = (function(){
449 452
 
450 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 466
       // Scroll to the altered text if it isn't visible
453 467
       var halfHeight = $c.height()/2, scrollHeight = $c.prop('scrollHeight'),
454 468
           textScrollY = inf.lineNum * scrollHeight/(inf.adv ? total_config_adv_lines : total_config_lines) - halfHeight;
@@ -458,7 +472,7 @@ var configuratorApp = (function(){
458 472
       else if (textScrollY > scrollHeight)
459 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 476
         $c.animate({ scrollTop: textScrollY < 0 ? 0 : textScrollY });
463 477
 
464 478
     },

読み込み中…
キャンセル
保存