Skip to content

Commit

Permalink
[changed] Rename Scrolling => ScrollHistory
Browse files Browse the repository at this point in the history
  • Loading branch information
mjackson committed Feb 16, 2015
1 parent 8276235 commit ae6fcda
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
10 changes: 6 additions & 4 deletions modules/Scrolling.js → modules/ScrollHistory.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,10 @@ function shouldUpdateScroll(state, prevState) {
* Provides the router with the ability to manage window scroll position
* according to its scroll behavior.
*/
var Scrolling = {
var ScrollHistory = {

statics: {

/**
* Records curent scroll position as the last known position for the given URL path.
*/
Expand All @@ -48,11 +49,12 @@ var Scrolling = {

return this.scrollHistory[path] || null;
}

},

componentWillMount: function () {
invariant(
this.getScrollBehavior() == null || canUseDOM,
this.constructor.getScrollBehavior() == null || canUseDOM,
'Cannot use scroll behavior without a DOM'
);
},
Expand All @@ -69,7 +71,7 @@ var Scrolling = {
if (!shouldUpdateScroll(this.state, prevState))
return;

var scrollBehavior = this.getScrollBehavior();
var scrollBehavior = this.constructor.getScrollBehavior();

if (scrollBehavior)
scrollBehavior.updateScrollPosition(
Expand All @@ -80,4 +82,4 @@ var Scrolling = {

};

module.exports = Scrolling;
module.exports = ScrollHistory;
12 changes: 6 additions & 6 deletions modules/createRouter.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ var HistoryLocation = require('./locations/HistoryLocation');
var RefreshLocation = require('./locations/RefreshLocation');
var StaticLocation = require('./locations/StaticLocation');
var NavigationContext = require('./NavigationContext');
var ScrollHistory = require('./ScrollHistory');
var StateContext = require('./StateContext');
var Scrolling = require('./Scrolling');
var createRoutesFromReactChildren = require('./Routing').createRoutesFromReactChildren;
var isReactChildren = require('./isReactChildren');
var Transition = require('./Transition');
Expand Down Expand Up @@ -442,11 +442,15 @@ function createRouter(options) {
location.removeChangeListener(Router.handleLocationChange);

this.isRunning = false;
},

getScrollBehavior: function () {
return scrollBehavior;
}

},

mixins: [ NavigationContext, StateContext, Scrolling ],
mixins: [ NavigationContext, StateContext, ScrollHistory ],

propTypes: {
children: PropTypes.falsy
Expand Down Expand Up @@ -482,10 +486,6 @@ function createRouter(options) {
return location;
},

getScrollBehavior: function () {
return scrollBehavior;
},

getRouteAtDepth: function (depth) {
var routes = this.state.routes;
return routes && routes[depth];
Expand Down

0 comments on commit ae6fcda

Please sign in to comment.