Scroll to reveal on switches as well
This commit is contained in:
parent
9c0adae3cd
commit
37c43a7ab3
1 changed files with 15 additions and 1 deletions
|
@ -399,6 +399,9 @@ var configuratorApp = (function(){
|
||||||
this.log(newline, 2);
|
this.log(newline, 2);
|
||||||
|
|
||||||
$c.text(txt);
|
$c.text(txt);
|
||||||
|
|
||||||
|
// Scroll to reveal the define
|
||||||
|
this.scrollToDefine(name);
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -449,6 +452,17 @@ var configuratorApp = (function(){
|
||||||
|
|
||||||
$c.text(txt);
|
$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
|
// Scroll to the altered text if it isn't visible
|
||||||
var halfHeight = $c.height()/2, scrollHeight = $c.prop('scrollHeight'),
|
var halfHeight = $c.height()/2, scrollHeight = $c.prop('scrollHeight'),
|
||||||
textScrollY = inf.lineNum * scrollHeight/(inf.adv ? total_config_adv_lines : total_config_lines) - halfHeight;
|
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)
|
else if (textScrollY > scrollHeight)
|
||||||
textScrollY = scrollHeight - 1;
|
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 });
|
$c.animate({ scrollTop: textScrollY < 0 ? 0 : textScrollY });
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
Reference in a new issue