Skip to content

Commit

Permalink
Fixes #294
Browse files Browse the repository at this point in the history
  • Loading branch information
kenwheeler committed May 25, 2017
1 parent 2e34bba commit 280394e
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 18 deletions.
1 change: 1 addition & 0 deletions src/components/manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -465,6 +465,7 @@ export default class Manager extends Component {
});
}
render() {
if (this.props.route.slide === null) return false;
const globals = this.props.route.params.indexOf('export') !== -1
? {
body: Object.assign(this.context.styles.global.body, {
Expand Down
45 changes: 27 additions & 18 deletions src/reducers/route.js
Original file line number Diff line number Diff line change
@@ -1,24 +1,33 @@
import { handleActions } from 'redux-actions';

const reducer = handleActions({
UPDATE_ROUTE: (state, action) => {
const { location, slideCount } = action.payload;
const slideHash = location.pathname.replace(/\//g, '');
let slide;
const reducer = handleActions(
{
UPDATE_ROUTE: (state, action) => {
const { location, slideCount } = action.payload;
const slideHash = location.pathname.replace(/\//g, '');
let slide;

if (isNaN(parseInt(slide))) {
slide = slideHash;
} else {
const proposedSlideIndex = parseInt(location.pathname.replace(/\//g, ''));
const isWithinBounds = proposedSlideIndex < slideCount && proposedSlideIndex >= 0;
slide = isWithinBounds ? proposedSlideIndex : 0;
}
if (isNaN(parseInt(slide))) {
slide = slideHash;
} else {
const proposedSlideIndex = parseInt(
location.pathname.replace(/\//g, '')
);
const isWithinBounds =
proposedSlideIndex < slideCount && proposedSlideIndex >= 0;
slide = isWithinBounds ? proposedSlideIndex : 0;
}

return Object.assign({}, {
slide,
params: location.search.replace('?', '').split('&')
});
}
}, { slide: 0, params: [] });
return Object.assign(
{},
{
slide,
params: location.search.replace('?', '').split('&'),
}
);
},
},
{ slide: null, params: [] }
);

export default reducer;

0 comments on commit 280394e

Please sign in to comment.