From 37c43a7ab3e5b985d1a29aa35cce4900a3f4a49f Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Fri, 6 Feb 2015 18:09:14 -0800 Subject: [PATCH] Scroll to reveal on switches as well --- Marlin/configurator/js/configurator.js | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/Marlin/configurator/js/configurator.js b/Marlin/configurator/js/configurator.js index 68ce56dcc..571809053 100644 --- a/Marlin/configurator/js/configurator.js +++ b/Marlin/configurator/js/configurator.js @@ -399,6 +399,9 @@ var configuratorApp = (function(){ this.log(newline, 2); $c.text(txt); + + // Scroll to reveal the define + this.scrollToDefine(name); }, /** @@ -449,6 +452,17 @@ var configuratorApp = (function(){ $c.text(txt); + // Scroll to reveal the define + this.scrollToDefine(name); + }, + + /** + * Scroll the field to show a define + */ + scrollToDefine: function(name, always) { + this.log('scrollToDefine:'+name,4); + var $elm = $('#'+name), inf = $elm[0].defineInfo, $c = $(inf.field); + // Scroll to the altered text if it isn't visible var halfHeight = $c.height()/2, scrollHeight = $c.prop('scrollHeight'), textScrollY = inf.lineNum * scrollHeight/(inf.adv ? total_config_adv_lines : total_config_lines) - halfHeight; @@ -458,7 +472,7 @@ var configuratorApp = (function(){ else if (textScrollY > scrollHeight) textScrollY = scrollHeight - 1; - if (Math.abs($c.prop('scrollTop') - textScrollY) > halfHeight) + if (always == true || Math.abs($c.prop('scrollTop') - textScrollY) > halfHeight) $c.animate({ scrollTop: textScrollY < 0 ? 0 : textScrollY }); },