... | ... |
@@ -9,13 +9,14 @@ function addExpander(div){ |
9 | 9 |
'class': 'pre_expander', |
10 | 10 |
'events': { |
11 | 11 |
'click': function(){ |
12 |
- toggleExpander(); |
|
12 |
+ toggleExpander(this); |
|
13 | 13 |
} |
14 | 14 |
} |
15 | 15 |
}).inject(div, 'top'); |
16 | 16 |
} |
17 |
-function toggleExpander(){ |
|
17 |
+function toggleExpander(expander){ |
|
18 | 18 |
var html = ''; |
19 |
+ var expanderPos = expander.getPosition().y; |
|
19 | 20 |
if($('main').toggleClass('expanded').hasClass('expanded')) |
20 | 21 |
html = '« contract'; |
21 | 22 |
else |
... | ... |
@@ -23,6 +24,11 @@ function toggleExpander(){ |
23 | 23 |
$$('div.highlight span.pre_expander').each(function(span){ |
24 | 24 |
span.set('html',html); |
25 | 25 |
}); |
26 |
+ fixScroll(expander, expanderPos); |
|
27 |
+} |
|
28 |
+function fixScroll(el, position){ |
|
29 |
+ pos = el.getPosition().y - position; |
|
30 |
+ window.scrollTo(window.getScroll().x ,window.getScroll().y + pos); |
|
26 | 31 |
} |
27 | 32 |
function enableCompressedLayout(codeblocks){ |
28 | 33 |
if(!codeblocks.length) return; |