Permalink
Browse files

Scrolling improvements.

  • Loading branch information...
1 parent 690b77e commit 24489137e4a760abbecb691747c24546845c33a6 @balupton balupton committed Feb 10, 2013
@@ -8,7 +8,12 @@ wait = (delay,callback) -> setTimeout(callback,delay)
# BevryApp
class BevryApp
+ config: null
+
constructor: ->
+ @config ?= {}
+ @config.articleScrollOpts ?= {}
+ @config.sectionScrollOpts ?= {}
$(@onDomReady)
@
@@ -78,6 +83,7 @@ class BevryApp
# Discover how we should handle the link
if event.which is 2 or event.metaKey or event.shiftKey
+ console.log('default')
action = 'default'
else
action = 'new'
@@ -162,7 +168,7 @@ class BevryApp
# State Change
stateChange: =>
# Prepare
- {$docHeaders,$docSectionWrapper} = @
+ {$docHeaders,$docSectionWrapper,config} = @
# Special handling for long docs
@$article = $article = $('#content article:first')
@@ -189,7 +195,7 @@ class BevryApp
.next('.section-wrapper')
.addClass('active')
.end()
- $header.ScrollTo({offsetTop:40}) if !opts or opts.scroll isnt false
+ $header.ScrollTo(config.sectionScrollOpts) if !opts or opts.scroll isnt false
.first()
.trigger('click',{scroll:false})
@@ -202,11 +208,14 @@ class BevryApp
$header = $(this)
.addClass('current')
.stop(true,false).css({'opacity':0.5}).animate({opacity:1},1000)
- $header.ScrollTo({offsetTop:40}) if !opts or opts.scroll isnt false
+ $header.ScrollTo(config.sectionScrollOpts) if !opts or opts.scroll isnt false
else
@$docHeaders = $docHeaders = null
+ # Scroll to the article
+ $article.ScrollTo(config.articleScrollOpts)
+
# Chain
@
@@ -5,6 +5,12 @@ standalone: true
# App
class App extends BevryApp
+ # Constructor
+ constructor: (args...) ->
+ super args...
+ @config.sectionScrollOpts.offsetTop = 40
+ @
+
# State Change
stateChange: (event,data) =>
# Check
@@ -184,7 +184,7 @@
});
// Complete the change
- if ( $body.ScrollTo||false ) { $body.ScrollTo(scrollOptions); } /* http://balupton.com/projects/jquery-scrollto */
+ // if ( $body.ScrollTo||false ) { $body.ScrollTo(scrollOptions); } /* http://balupton.com/projects/jquery-scrollto */
$body.removeClass('loading');
$window.trigger(completedEventName, {$dataBody:$dataBody});

0 comments on commit 2448913

Please sign in to comment.