Merge pull request #4354 from paulkaplan/fix-backpack-sprite

Fix issue where you couldn't add sprites from backpack when there are no sprites
This commit is contained in:
Karishma Chadha authored and GitHub committed 2019-01-16 15:39:13 -05:00
commit 97f8eb63b4
4 files changed
+6 -7

No files matched your search

+1 -1
View File
@@ -206,7 +206,7 @@ class CostumeTab extends React.Component {
this.fileInput.click();
}
handleDrop (dropInfo) {
if (dropInfo.dragType === DragConstants.COSTUME) {
if (dropInfo.dragType === DragConstants.COSTUME && dropInfo.newIndex !== null) {
const sprite = this.props.vm.editingTarget.sprite;
const activeCostume = sprite.costumes[this.state.selectedCostumeIndex];
this.props.vm.reorderCostume(this.props.vm.editingTarget.id,
+1 -1
View File
@@ -130,7 +130,7 @@ class SoundTab extends React.Component {
}
handleDrop (dropInfo) {
if (dropInfo.dragType === DragConstants.SOUND) {
if (dropInfo.dragType === DragConstants.SOUND && dropInfo.newIndex !== null) {
const sprite = this.props.vm.editingTarget.sprite;
const activeSound = sprite.sounds[this.state.selectedSoundIndex];
+1 -1
View File
@@ -163,7 +163,7 @@ class TargetPane extends React.Component {
}
handleDrop (dragInfo) {
const {sprite: targetId} = this.props.hoveredTarget;
if (dragInfo.dragType === DragConstants.SPRITE) {
if (dragInfo.dragType === DragConstants.SPRITE && dragInfo.newIndex !== null) {
// Add one to both new and target index because we are not counting/moving the stage
this.props.vm.reorderTarget(dragInfo.index + 1, dragInfo.newIndex + 1);
} else if (dragInfo.dragType === DragConstants.BACKPACK_SPRITE) {
+3 -4
View File
@@ -33,10 +33,9 @@ const SortableHOC = function (WrappedComponent) {
}
this.containerBox = this.ref.getBoundingClientRect();
} else if (!newProps.dragInfo.dragging && this.props.dragInfo.dragging) {
const newIndex = this.getMouseOverIndex();
if (newIndex !== null) {
this.props.onDrop(Object.assign({}, this.props.dragInfo, {newIndex}));
}
this.props.onDrop(Object.assign({}, this.props.dragInfo, {
newIndex: this.getMouseOverIndex()
}));
}
}