Skip to content

Commit

Permalink
Make sure passages remain onscreen
Browse files Browse the repository at this point in the history
Resolves #280
  • Loading branch information
klembot committed Oct 20, 2016
1 parent 2154883 commit 52fbd02
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions src/data/story.js
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,19 @@ const storyStore = module.exports = {
props
);

/*
Force the top and left properties to be at least zero, to keep
passages onscreen.
*/

if (newPassage.left < 0) {
newPassage.left = 0;
}

if (newPassage.top < 0) {
newPassage.top = 0;
}

newPassage.story = story.id;
story.passages.push(newPassage);

Expand All @@ -145,6 +158,19 @@ const storyStore = module.exports = {
UPDATE_PASSAGE_IN_STORY(state, storyId, passageId, props) {
let story = getStoryById(state, storyId);

/*
Force the top and left properties to be at least zero, to keep
passages onscreen.
*/

if (props.left && props.left < 0) {
props.left = 0;
}

if (props.top && props.top < 0) {
props.top = 0;
}

Object.assign(getPassageInStory(story, passageId), props);
story.lastUpdate = new Date();
},
Expand Down

0 comments on commit 52fbd02

Please sign in to comment.