Skip to content

Commit

Permalink
fix: chance RangeError
Browse files Browse the repository at this point in the history
  • Loading branch information
Pierre Haller committed Apr 22, 2020
1 parent 358baf3 commit 3856336
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions src/species/clicker.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ const getDefaultConfig = (randomizer) => {
const defaultPositionSelector = () => {
return [
randomizer.natural({
max: document.documentElement.clientWidth - 1,
max: Math.max(0, document.documentElement.clientWidth - 1),
}),
randomizer.natural({
max: document.documentElement.clientHeight - 1,
max: Math.max(0, document.documentElement.clientHeight - 1),
}),
];
};
Expand Down
4 changes: 2 additions & 2 deletions src/species/toucher.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ const getDefaultConfig = (randomizer) => {
const defaultPositionSelector = () => {
return [
randomizer.natural({
max: document.documentElement.clientWidth - 1,
max: Math.max(0, document.documentElement.clientWidth - 1),
}),
randomizer.natural({
max: document.documentElement.clientHeight - 1,
max: Math.max(0, document.documentElement.clientHeight - 1),
}),
];
};
Expand Down
4 changes: 2 additions & 2 deletions src/species/typer.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,10 @@ export default (userConfig) => (logger, randomizer) => {
const eventType = randomizer.pick(config.eventTypes);
const key = config.keyGenerator();
const posX = randomizer.natural({
max: documentElement.clientWidth - 1,
max: Math.max(0, documentElement.clientWidth - 1),
});
const posY = randomizer.natural({
max: documentElement.clientHeight - 1,
max: Math.max(0, documentElement.clientHeight - 1),
});
const targetElement = config.targetElement(posX, posY);

Expand Down

0 comments on commit 3856336

Please sign in to comment.