@@ -2,10 +2,7 @@ var React = require('react');
2
2
var warning = require ( 'react/lib/warning' ) ;
3
3
var canUseDOM = require ( 'react/lib/ExecutionEnvironment' ) . canUseDOM ;
4
4
var copyProperties = require ( 'react/lib/copyProperties' ) ;
5
- var LocationActions = require ( '../actions/LocationActions' ) ;
6
- var LocationDispatcher = require ( '../dispatchers/LocationDispatcher' ) ;
7
5
var PathStore = require ( '../stores/PathStore' ) ;
8
- var ScrollStore = require ( '../stores/ScrollStore' ) ;
9
6
var reversedArray = require ( '../utils/reversedArray' ) ;
10
7
var Transition = require ( '../utils/Transition' ) ;
11
8
var Redirect = require ( '../utils/Redirect' ) ;
@@ -265,13 +262,6 @@ function computeHandlerProps(matches, query) {
265
262
266
263
var BrowserTransitionHandling = {
267
264
268
- handleTransition : function ( transition ) {
269
- LocationDispatcher . handleViewAction ( {
270
- type : LocationActions . FINISHED_TRANSITION ,
271
- path : transition . path
272
- } ) ;
273
- } ,
274
-
275
265
handleTransitionError : function ( error ) {
276
266
throw error ; // This error probably originated in a transition hook.
277
267
} ,
@@ -290,10 +280,6 @@ var BrowserTransitionHandling = {
290
280
291
281
var ServerTransitionHandling = {
292
282
293
- handleTransition : function ( transition ) {
294
- // TODO
295
- } ,
296
-
297
283
handleTransitionError : function ( error ) {
298
284
// TODO
299
285
} ,
@@ -330,20 +316,9 @@ var Routes = React.createClass({
330
316
mixins : [ ActiveContext , LocationContext , RouteContext , ScrollContext ] ,
331
317
332
318
propTypes : {
333
- onTransition : React . PropTypes . func . isRequired ,
334
- onTransitionError : React . PropTypes . func . isRequired ,
335
- onAbortedTransition : React . PropTypes . func . isRequired ,
336
319
initialPath : React . PropTypes . string
337
320
} ,
338
321
339
- getDefaultProps : function ( ) {
340
- return {
341
- onTransition : TransitionHandling . handleTransition ,
342
- onTransitionError : TransitionHandling . handleTransitionError ,
343
- onAbortedTransition : TransitionHandling . handleAbortedTransition
344
- } ;
345
- } ,
346
-
347
322
getInitialState : function ( ) {
348
323
return {
349
324
matches : [ ]
@@ -356,41 +331,35 @@ var Routes = React.createClass({
356
331
357
332
componentDidMount : function ( ) {
358
333
PathStore . addChangeListener ( this . handlePathChange ) ;
359
- ScrollStore . addChangeListener ( this . handleScrollChange ) ;
360
334
} ,
361
335
362
336
componentWillUnmount : function ( ) {
363
- ScrollStore . removeChangeListener ( this . handleScrollChange ) ;
364
337
PathStore . removeChangeListener ( this . handlePathChange ) ;
365
338
} ,
366
339
367
340
handlePathChange : function ( _path ) {
368
341
var path = _path || PathStore . getCurrentPath ( ) ;
342
+ var actionType = PathStore . getCurrentActionType ( ) ;
369
343
370
344
if ( this . state . path === path )
371
345
return ; // Nothing to do!
372
346
347
+ if ( this . state . path )
348
+ this . recordScroll ( this . state . path ) ;
349
+
373
350
var self = this ;
374
351
375
352
this . dispatch ( path , function ( error , transition ) {
376
353
if ( error ) {
377
- self . props . onTransitionError . call ( self , error ) ;
354
+ TransitionHandling . handleTransitionError . call ( self , error ) ;
378
355
} else if ( transition . isAborted ) {
379
- self . props . onAbortedTransition . call ( self , transition ) ;
356
+ TransitionHandling . handleAbortedTransition . call ( self , transition ) ;
380
357
} else {
381
- self . props . onTransition . call ( self , transition ) ;
358
+ self . updateScroll ( path , actionType ) ;
382
359
}
383
360
} ) ;
384
361
} ,
385
362
386
- handleScrollChange : function ( ) {
387
- var behavior = this . getScrollBehavior ( ) ;
388
- var position = ScrollStore . getCurrentScrollPosition ( ) ;
389
-
390
- if ( behavior && position )
391
- behavior . updateScrollPosition ( position , PathStore . getCurrentActionType ( ) ) ;
392
- } ,
393
-
394
363
/**
395
364
* Performs a depth-first search for the first route in the tree that matches on
396
365
* the given path. Returns an array of all routes in the tree leading to the one
0 commit comments