@@ -10,9 +10,9 @@ get-offset = ->
1010scroll -to = (anchor ) ->
1111 offset = $ "span[data-id='#{anchor}']" .offset!
1212 if offset
13- $ 'html, body' .animate do
14- scroll - top : ( offset ?.top or 0 ) - ( window .top- offset or 0 )
15- , 200ms
13+ dist = ( offset ?.top or 0 ) - ( window .top- offset or 0 )
14+ x = $ 'html, body' .animate { scrollTop : dist }, 200ms, ->
15+ #console.log "Animation is completed?"
1616
1717make -link = (scene , anchor ) ->
1818 curr = parse -link get -window -hash !
@@ -108,7 +108,8 @@ Ractive.components['a'] = Ractive.extend do
108108 return
109109 else if link
110110 generated -link = make -link link .scene, link .anchor
111- #console.log "setting window hash by '<a>' to ", generated-link
111+ if @get \debug
112+ console .log "setting window hash by '<a>' to " , generated -link
112113
113114 # WORKAROUND: jquery.scrollTop! is somehow
114115 # set to 0 when `set-window-hash` is called.
@@ -122,7 +123,7 @@ Ractive.components['a'] = Ractive.extend do
122123
123124Ractive .components['anchor' ] = Ractive .extend do
124125 template : require('./anchor.html' )
125- isolated : yes
126+ isolated : no
126127
127128
128129Ractive .components['router' ] = Ractive .extend do
@@ -194,6 +195,7 @@ Ractive.components['router'] = Ractive.extend do
194195
195196 unless opts .noscroll
196197 sleep 50ms, -> scroll -to curr .anchor
198+ null
197199
198200 actor .send 'app.router.changes' , {change }
199201 @set \@shared .router, change
@@ -209,9 +211,10 @@ Ractive.components['router'] = Ractive.extend do
209211 #console.log "fired hash listener! hash is: #{hash}"
210212 handle -hash !
211213
212- $ window .on \ hashchange , ->
214+ window .addEventListener ' hashchange' , ( ->
213215 console .log "this is hashchange run: #{window.location.hash}"
214216 handle -hash !
217+ ), false
215218
216219 # on app-load
217220 handle -hash !
0 commit comments