mirror of
https://github.com/muerwre/orchidmap-front.git
synced 2025-04-25 11:06:40 +07:00
forwards and backwards drawing
This commit is contained in:
parent
bbd7d6a89a
commit
ad676d5fde
11 changed files with 119 additions and 21 deletions
|
@ -2,19 +2,20 @@ import React, { FC, useEffect, memo, useState, useCallback } from 'react';
|
|||
import { InteractivePoly } from '~/utils/map/InteractivePoly';
|
||||
import { isMobile } from '~/utils/window';
|
||||
import { LatLng } from 'leaflet';
|
||||
import { selectEditor, selectEditorMode, selectEditorEditing } from '~/redux/editor/selectors';
|
||||
import pick from 'ramda/es/pick';
|
||||
import { selectEditorMode, selectEditorEditing, selectEditorDirection } from '~/redux/editor/selectors';
|
||||
import * as MAP_ACTIONS from '~/redux/map/actions';
|
||||
import { connect } from 'react-redux';
|
||||
import { selectMap, selectMapRoute } from '~/redux/map/selectors';
|
||||
import { selectMapRoute } from '~/redux/map/selectors';
|
||||
import { MainMap } from '~/constants/map';
|
||||
import { MODES } from '~/constants/modes';
|
||||
import * as EDITOR_ACTIONS from '~/redux/editor/actions';
|
||||
import { IState } from '~/redux/store';
|
||||
|
||||
const mapStateToProps = state => ({
|
||||
const mapStateToProps = (state: IState) => ({
|
||||
mode: selectEditorMode(state),
|
||||
editing: selectEditorEditing(state),
|
||||
route: selectMapRoute(state),
|
||||
drawing_direction: selectEditorDirection(state),
|
||||
});
|
||||
|
||||
const mapDispatchToProps = {
|
||||
|
@ -26,7 +27,7 @@ const mapDispatchToProps = {
|
|||
type Props = ReturnType<typeof mapStateToProps> & typeof mapDispatchToProps & {};
|
||||
|
||||
const RouteUnconnected: FC<Props> = memo(
|
||||
({ route, editing, mode, mapSetRoute, editorSetDistance, editorSetMarkersShown }) => {
|
||||
({ route, editing, mode, drawing_direction, mapSetRoute, editorSetDistance, editorSetMarkersShown }) => {
|
||||
const [layer, setLayer] = useState<InteractivePoly>(null);
|
||||
|
||||
const onDistanceChange = useCallback(({ distance }) => editorSetDistance(distance), [
|
||||
|
@ -103,6 +104,12 @@ const RouteUnconnected: FC<Props> = memo(
|
|||
}
|
||||
}, [mode, layer]);
|
||||
|
||||
useEffect(() => {
|
||||
if (!layer) return;
|
||||
|
||||
layer.setDirection(drawing_direction);
|
||||
}, [drawing_direction, layer]);
|
||||
|
||||
return null;
|
||||
}
|
||||
);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue