mirror of
https://github.com/twisterarmy/twister-react.git
synced 2025-01-27 07:04:20 +00:00
29 lines
663 B
JavaScript
Executable File
29 lines
663 B
JavaScript
Executable File
'use strict';
|
|
|
|
var LocationActions = require('../actions/LocationActions');
|
|
|
|
/**
|
|
* A scroll behavior that attempts to imitate the default behavior
|
|
* of modern browsers.
|
|
*/
|
|
var ImitateBrowserBehavior = {
|
|
|
|
updateScrollPosition: function updateScrollPosition(position, actionType) {
|
|
switch (actionType) {
|
|
case LocationActions.PUSH:
|
|
case LocationActions.REPLACE:
|
|
window.scrollTo(0, 0);
|
|
break;
|
|
case LocationActions.POP:
|
|
if (position) {
|
|
window.scrollTo(position.x, position.y);
|
|
} else {
|
|
window.scrollTo(0, 0);
|
|
}
|
|
break;
|
|
}
|
|
}
|
|
|
|
};
|
|
|
|
module.exports = ImitateBrowserBehavior; |