Skip to content

Commit

Permalink
fixed zoom animation skip by consecutive multiple map updates.
Browse files Browse the repository at this point in the history
  • Loading branch information
omiinaya committed Mar 10, 2022
1 parent d95fc39 commit bdc2b4d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 14 deletions.
21 changes: 8 additions & 13 deletions src/components/Markers.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import IMarker, { IMarkerData } from "../interfaces/IMarker";
import { useAppDispatch } from "../store/hooks";
import { getZone } from "../api/Zone";
import { getWorld } from "../api/World";
import { selectZone, closeZone } from "../store/slices/Zone";
import { closeZone } from "../store/slices/Zone";

export default (markers: Array<IMarker>) => {
const dispatch = useAppDispatch();
Expand Down Expand Up @@ -33,23 +33,18 @@ export default (markers: Array<IMarker>) => {
icon={icon}
position={position}
eventHandlers={{
click: () => {
click: async () => {
if (data.destinationID) {
let destination: any;
if (data.destinationID === "overworld") {
destination = "00000";
dispatch(closeZone());
dispatch(closeZone())
} else {
destination = data.destinationID;

dispatch(getWorld()).then((data) => {
const zones: any = data.payload.zones;
const zone: any = zones.filter(
(z: any) => z.id === destination
)[0];
dispatch(closeZone());
dispatch(getZone(zone));
});
const world = await dispatch(getWorld())
const zones = world.payload.zones;
const zone = zones.filter((z:any) => z.id === destination)[0];
dispatch(closeZone())
setTimeout(() => { dispatch(getZone(zone)); }, 500);
}
}
},
Expand Down
2 changes: 1 addition & 1 deletion src/store/slices/Zone.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export const worldSlice = createSlice({
name: 'zone',
initialState,
reducers: {
closeZone: (state) => {
closeZone: (state) => {
state.zone = null;
}
},
Expand Down

0 comments on commit bdc2b4d

Please sign in to comment.