Track drag status via store

This commit is contained in:
Roman Cervantes 2019-12-16 12:05:52 -07:00
parent 2c1d24d201
commit b3cfa56cf2
4 changed files with 11 additions and 13 deletions

View file

@ -114,7 +114,7 @@ export default {
}, },
computed: { computed: {
...mapState(['user', 'gameLists', 'platform', 'settings', 'games']), ...mapState(['user', 'gameLists', 'platform', 'settings', 'games', 'dragging']),
autoSortEnabled() { autoSortEnabled() {
const list = this.list[this.listIndex]; const list = this.list[this.listIndex];
@ -241,12 +241,12 @@ export default {
}, },
dragStart({ item }) { dragStart({ item }) {
this.dragging = true; this.$store.commit('SET_DRAGGING_STATUS', true);
this.draggingId = item.id; this.draggingId = item.id;
this.$emit('dragStart');
}, },
dragEnd() { dragEnd() {
this.$store.commit('SET_DRAGGING_STATUS', false);
this.$emit('dragEnd'); this.$emit('dragEnd');
}, },
}, },
@ -268,8 +268,8 @@ export default {
max-height: calc(100vh - 100px); max-height: calc(100vh - 100px);
@media($small) { @media($small) {
.games {
&:not(.dragging) { &:not(.dragging) {
.games {
scroll-snap-type: y mandatory; scroll-snap-type: y mandatory;
scroll-padding: $gp / 2; scroll-padding: $gp / 2;

View file

@ -9,7 +9,6 @@
:game-list="list.games" :game-list="list.games"
:list-index="listIndex" :list-index="listIndex"
:key="`${list.name}-${listIndex}`" :key="`${list.name}-${listIndex}`"
@dragStart="dragStart"
@dragEnd="dragEnd" @dragEnd="dragEnd"
/> />
@ -41,7 +40,6 @@ export default {
data() { data() {
return { return {
dragging: false,
draggingId: null, draggingId: null,
loading: false, loading: false,
gameData: null, gameData: null,
@ -51,7 +49,7 @@ export default {
}, },
computed: { computed: {
...mapState(['user', 'gameLists', 'platform', 'games']), ...mapState(['user', 'gameLists', 'platform', 'games', 'dragging']),
list() { list() {
return this.gameLists && this.platform && this.gameLists[this.platform.code] return this.gameLists && this.platform && this.gameLists[this.platform.code]
@ -74,12 +72,7 @@ export default {
}, },
methods: { methods: {
dragStart() {
this.dragging = true;
},
dragEnd() { dragEnd() {
this.dragging = false;
this.draggingId = null; this.draggingId = null;
this.updateLists(); this.updateLists();
}, },

View file

@ -49,6 +49,10 @@ export default {
state.tags = tags; state.tags = tags;
}, },
SET_DRAGGING_STATUS(state, status) {
state.dragging = status;
},
SET_NOTES(state, notes) { SET_NOTES(state, notes) {
state.notes = notes; state.notes = notes;
}, },

View file

@ -3,6 +3,7 @@ export default {
releases: null, releases: null,
tags: {}, tags: {},
notes: {}, notes: {},
dragging: false,
activeListIndex: null, activeListIndex: null,
gameLists: {}, gameLists: {},
settings: null, settings: null,