@@ -2,10 +2,7 @@ var React = require('react');
22var warning = require ( 'react/lib/warning' ) ;
33var canUseDOM = require ( 'react/lib/ExecutionEnvironment' ) . canUseDOM ;
44var copyProperties = require ( 'react/lib/copyProperties' ) ;
5- var LocationActions = require ( '../actions/LocationActions' ) ;
6- var LocationDispatcher = require ( '../dispatchers/LocationDispatcher' ) ;
75var PathStore = require ( '../stores/PathStore' ) ;
8- var ScrollStore = require ( '../stores/ScrollStore' ) ;
96var reversedArray = require ( '../utils/reversedArray' ) ;
107var Transition = require ( '../utils/Transition' ) ;
118var Redirect = require ( '../utils/Redirect' ) ;
@@ -265,13 +262,6 @@ function computeHandlerProps(matches, query) {
265262
266263var BrowserTransitionHandling = {
267264
268- handleTransition : function ( transition ) {
269- LocationDispatcher . handleViewAction ( {
270- type : LocationActions . FINISHED_TRANSITION ,
271- path : transition . path
272- } ) ;
273- } ,
274-
275265 handleTransitionError : function ( error ) {
276266 throw error ; // This error probably originated in a transition hook.
277267 } ,
@@ -290,10 +280,6 @@ var BrowserTransitionHandling = {
290280
291281var ServerTransitionHandling = {
292282
293- handleTransition : function ( transition ) {
294- // TODO
295- } ,
296-
297283 handleTransitionError : function ( error ) {
298284 // TODO
299285 } ,
@@ -330,20 +316,9 @@ var Routes = React.createClass({
330316 mixins : [ ActiveContext , LocationContext , RouteContext , ScrollContext ] ,
331317
332318 propTypes : {
333- onTransition : React . PropTypes . func . isRequired ,
334- onTransitionError : React . PropTypes . func . isRequired ,
335- onAbortedTransition : React . PropTypes . func . isRequired ,
336319 initialPath : React . PropTypes . string
337320 } ,
338321
339- getDefaultProps : function ( ) {
340- return {
341- onTransition : TransitionHandling . handleTransition ,
342- onTransitionError : TransitionHandling . handleTransitionError ,
343- onAbortedTransition : TransitionHandling . handleAbortedTransition
344- } ;
345- } ,
346-
347322 getInitialState : function ( ) {
348323 return {
349324 matches : [ ]
@@ -356,41 +331,35 @@ var Routes = React.createClass({
356331
357332 componentDidMount : function ( ) {
358333 PathStore . addChangeListener ( this . handlePathChange ) ;
359- ScrollStore . addChangeListener ( this . handleScrollChange ) ;
360334 } ,
361335
362336 componentWillUnmount : function ( ) {
363- ScrollStore . removeChangeListener ( this . handleScrollChange ) ;
364337 PathStore . removeChangeListener ( this . handlePathChange ) ;
365338 } ,
366339
367340 handlePathChange : function ( _path ) {
368341 var path = _path || PathStore . getCurrentPath ( ) ;
342+ var actionType = PathStore . getCurrentActionType ( ) ;
369343
370344 if ( this . state . path === path )
371345 return ; // Nothing to do!
372346
347+ if ( this . state . path )
348+ this . recordScroll ( this . state . path ) ;
349+
373350 var self = this ;
374351
375352 this . dispatch ( path , function ( error , transition ) {
376353 if ( error ) {
377- self . props . onTransitionError . call ( self , error ) ;
354+ TransitionHandling . handleTransitionError . call ( self , error ) ;
378355 } else if ( transition . isAborted ) {
379- self . props . onAbortedTransition . call ( self , transition ) ;
356+ TransitionHandling . handleAbortedTransition . call ( self , transition ) ;
380357 } else {
381- self . props . onTransition . call ( self , transition ) ;
358+ self . updateScroll ( path , actionType ) ;
382359 }
383360 } ) ;
384361 } ,
385362
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-
394363 /**
395364 * Performs a depth-first search for the first route in the tree that matches on
396365 * the given path. Returns an array of all routes in the tree leading to the one
0 commit comments