Merge pull request #268 from fsih/flipAll

Flip all
This commit is contained in:
DD Liu 2018-01-30 15:57:30 -05:00 committed by GitHub
commit 0a308e8e44
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 4 deletions

View file

@ -151,13 +151,11 @@ const ModeToolsComponent = props => {
</InputGroup>
<InputGroup className={classNames(styles.modLabeledIconHeight)}>
<LabeledIconButton
disabled={!props.selectedItems.length}
imgSrc={flipHorizontalIcon}
title={props.intl.formatMessage(messages.flipHorizontal)}
onClick={props.onFlipHorizontal}
/>
<LabeledIconButton
disabled={!props.selectedItems.length}
imgSrc={flipVerticalIcon}
title={props.intl.formatMessage(messages.flipVertical)}
onClick={props.onFlipVertical}

View file

@ -7,7 +7,7 @@ import bindAll from 'lodash.bindall';
import ModeToolsComponent from '../components/mode-tools/mode-tools.jsx';
import {clearSelectedItems, setSelectedItems} from '../reducers/selected-items';
import {incrementPasteOffset, setClipboardItems} from '../reducers/clipboard';
import {clearSelection, getSelectedLeafItems, getSelectedRootItems} from '../helper/selection';
import {clearSelection, getSelectedLeafItems, getSelectedRootItems, getAllRootItems} from '../helper/selection';
import {HANDLE_RATIO, ensureClockwise} from '../helper/math';
class ModeTools extends React.Component {
@ -137,7 +137,11 @@ class ModeTools extends React.Component {
}
}
_handleFlip (horizontalScale, verticalScale) {
const selectedItems = getSelectedRootItems();
let selectedItems = getSelectedRootItems();
if (selectedItems.length === 0) {
// If nothing is selected, select everything
selectedItems = getAllRootItems();
}
// Record old indices
for (const item of selectedItems) {
item.data.index = item.index;