Unified · Split
| @@ -99,14 +99,12 @@ class app.views.Content extends app.View · 98 unmodified lines | |||
| 99 | return | 99 | return |
| 100 | 100 | ||
| 101 | scrollToTarget: -> | 101 | scrollToTarget: -> |
| 102 | return if @isLoading() | ||
| 103 | if @routeCtx.hash and el = @findTargetByHash @routeCtx.hash | 102 | if @routeCtx.hash and el = @findTargetByHash @routeCtx.hash |
| 104 | $.scrollToWithImageLock el, @scrollEl, 'top', | 103 | $.scrollToWithImageLock el, @scrollEl, 'top', |
| 105 | margin: if @scrollEl is @el then 0 else $.offset(@el).top | 104 | margin: if @scrollEl is @el then 0 else $.offset(@el).top |
| 106 | $.highlight el, className: '_highlight' | 105 | $.highlight el, className: '_highlight' |
| 107 | else | 106 | else |
| 108 | @scrollTo @scrollMap[@routeCtx.state.id] | 107 | @scrollTo @scrollMap[@routeCtx.state.id] |
| 109 | clearTimeout @scrollTimeout | ||
| 110 | return | 108 | return |
| 111 | 109 | ||
| 112 | onReady: => | 110 | onReady: => |
| @@ -120,21 +118,28 @@ class app.views.Content extends app.View · 7 unmodified lines | |||
| 120 | 118 | ||
| 121 | onEntryLoading: => | 119 | onEntryLoading: => |
| 122 | @showLoading() | 120 | @showLoading() |
| 121 | if @scrollToTargetTimeout | ||
| 122 | clearTimeout @scrollToTargetTimeout | ||
| 123 | @scrollToTargetTimeout = null | ||
| 123 | return | 124 | return |
| 124 | 125 | ||
| 125 | onEntryLoaded: => | 126 | onEntryLoaded: => |
| 126 | @hideLoading() | 127 | @hideLoading() |
| 128 | if @scrollToTargetTimeout | ||
| 129 | clearTimeout @scrollToTargetTimeout | ||
| 130 | @scrollToTargetTimeout = null | ||
| 127 | @scrollToTarget() | 131 | @scrollToTarget() |
| 128 | return | 132 | return |
| 129 | 133 | ||
| 130 | beforeRoute: (context) => | 134 | beforeRoute: (context) => |
| 131 | @cacheScrollPosition() | 135 | @cacheScrollPosition() |
| 132 | @routeCtx = context | 136 | @routeCtx = context |
| 133 | @scrollTimeout = @delay @scrollToTarget | 137 | @scrollToTargetTimeout = @delay @scrollToTarget |
| 134 | return | 138 | return |
| 135 | 139 | ||
| 136 | cacheScrollPosition: -> | 140 | cacheScrollPosition: -> |
| 137 | return if not @routeCtx or @routeCtx.hash | 141 | return if not @routeCtx or @routeCtx.hash |
| 142 | return if @routeCtx.path is '/' | ||
| 138 | 143 | ||
| 139 | unless @scrollMap[@routeCtx.state.id]? | 144 | unless @scrollMap[@routeCtx.state.id]? |
| 140 | @scrollStack.push @routeCtx.state.id | 145 | @scrollStack.push @routeCtx.state.id |