aboutsummaryrefslogtreecommitdiff
path: root/source
diff options
context:
space:
mode:
authorB Mathis <brandon@imathis.com>2009-11-12 13:23:01 -0600
committerB Mathis <brandon@imathis.com>2009-11-12 13:23:01 -0600
commit0ac4eca1d49103b17d1dc2a37e1c6c6f7845ef9d (patch)
tree6285fece6562d52478045dc3ed04b8f4ca3fee3f /source
parenta23a4734b48c34158b7aab8d6431b6157c8ab7e2 (diff)
downloadmy_new_personal_website-0ac4eca1d49103b17d1dc2a37e1c6c6f7845ef9d.tar.xz
my_new_personal_website-0ac4eca1d49103b17d1dc2a37e1c6c6f7845ef9d.zip
expanding code now adjusts the scroll position to accommodate for differently wrapped text
Diffstat (limited to 'source')
-rw-r--r--source/javascripts/octopress.js10
1 files changed, 8 insertions, 2 deletions
diff --git a/source/javascripts/octopress.js b/source/javascripts/octopress.js
index 961fa461..8e7c1a4f 100644
--- a/source/javascripts/octopress.js
+++ b/source/javascripts/octopress.js
@@ -9,13 +9,14 @@ function addExpander(div){
'class': 'pre_expander',
'events': {
'click': function(){
- toggleExpander();
+ toggleExpander(this);
}
}
}).inject(div, 'top');
}
-function toggleExpander(){
+function toggleExpander(expander){
var html = '';
+ var expanderPos = expander.getPosition().y;
if($('main').toggleClass('expanded').hasClass('expanded'))
html = '&laquo; contract';
else
@@ -23,6 +24,11 @@ function toggleExpander(){
$$('div.highlight span.pre_expander').each(function(span){
span.set('html',html);
});
+ fixScroll(expander, expanderPos);
+}
+function fixScroll(el, position){
+ pos = el.getPosition().y - position;
+ window.scrollTo(window.getScroll().x ,window.getScroll().y + pos);
}
function enableCompressedLayout(codeblocks){
if(!codeblocks.length) return;