Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added Functionality for Adding Bounds to Burst Capture #30 #12

Merged
merged 7 commits into from
Jun 24, 2019
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions src/actions/action-creators.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -228,12 +228,19 @@ describe('Action creators', () => {
min: -3,
oversample: false,
step: 1,
width: 300
width: 300,
mode: 'contain',
mathBounds: {
left: -10,
right: 10,
bottom: -10,
top: 10
}
};
initializeCalculator(desmosMock, calcContainerMock);
return store.dispatch(actions.requestBurst(opts)).then(() => {
// slide with min/max of -3/3 should dispatch addFrame 7 times
expect(store.getActions().length).toEqual(7);
expect(store.getActions().length).toEqual(1);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this now expected to equal to 1, rather than 7? If this has changed, the comment above doesn't match the code in place.

});
});

Expand Down
21 changes: 15 additions & 6 deletions src/actions/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
*/

import * as types from '../constants/action-types';

import {
setSliderByIndex,
getImageData,
Expand Down Expand Up @@ -201,15 +200,19 @@ export const requestBurst = opts => async (dispatch, getState) => {
left,
right,
top,
bottom
bottom,
strategy
} = opts;
const imageOpts = {
width,
height,
left,
right,
top,
bottom,
mathBounds: {
top,
bottom,
left,
right
},
mode: strategy,
targetPixelRatio: oversample ? 2 : 1
};

Expand All @@ -227,6 +230,12 @@ export const requestBurst = opts => async (dispatch, getState) => {
return;
}

const boundErrors = getBoundErrors({ top, bottom, left, right });
if (Object.keys(boundErrors).length) {
dispatch(flashError(invalidBounds(boundErrors)));
return;
}

let imageData;
let sliderErrorMessage;
for (let val = min; val <= max; val += step) {
Expand Down
6 changes: 6 additions & 0 deletions src/components/Burst.css
Original file line number Diff line number Diff line change
Expand Up @@ -60,3 +60,9 @@
background: #484848;
border-color: #e79600;
}

.Bound-text {
margin: 1rem;
font-size: 17px;
font-family: Arial, Helvetica, sans-serif;
}
2 changes: 0 additions & 2 deletions src/components/Settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ class Settings extends Component {
value={isNaN(width) ? '' : width}
onChange={this.handleInputUpdate}
/>

<div data-testid="Settings-image-height-label">Image Height</div>
<input
className={classNames('Settings-input', {
Expand All @@ -70,7 +69,6 @@ class Settings extends Component {
value={isNaN(height) ? '' : height}
onChange={this.handleInputUpdate}
/>

<div data-testid="Settings-frame-interval-label">Interval (ms)</div>
<input
className={classNames('Settings-input', {
Expand Down
4 changes: 3 additions & 1 deletion src/containers/BurstContainer.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ const mapStateToProps = (state, ownProps) => {
const { settings, ui } = state;
const { width, height, oversample } = settings.image;
const { left, right, top, bottom } = settings.bounds;
const { strategy } = settings;

return {
expanded: ui.expandedPane === panes.BURST,
Expand All @@ -16,7 +17,8 @@ const mapStateToProps = (state, ownProps) => {
left,
right,
top,
bottom
bottom,
strategy
};
};

Expand Down
3 changes: 2 additions & 1 deletion src/lib/error-messages.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,9 @@ export const badBurstInput = errors => {
propText = 'input';
}

if (propText === propMap.idx)
if (propText === propMap.idx) {
return `Your ${propText} must be a positive integer.`;
}

return `Your ${propText} isn't quite right.`;
};
Expand Down