Skip to content

Commit

Permalink
[fix] Improved split+unsynced mode for better handling (#2176)
Browse files Browse the repository at this point in the history
  • Loading branch information
igorDykhta committed Mar 30, 2023
1 parent 9057272 commit 485252a
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 4 deletions.
1 change: 1 addition & 0 deletions src/components/src/index.ts
Expand Up @@ -264,6 +264,7 @@ export type {DatasetTagProps} from './side-panel/common/dataset-tag';
export type {CustomPanelsProps} from './side-panel/custom-panel';
export type {LayerTypeListItemType} from './side-panel/layer-panel/layer-type-list-item';
export type {LayerGroupColorPickerProps} from './side-panel/map-style-panel/map-layer-group-color-picker';
export type {MapLegendPanelProps, MapLegendPanelFactoryDeps} from './map/map-legend-panel';

export {
Icons,
Expand Down
6 changes: 4 additions & 2 deletions src/components/src/map/map-control-panel.tsx
Expand Up @@ -116,6 +116,7 @@ export type MapControlPanelProps = {
logoComponent?: Element;
mapState?: MapState;
onToggleSplitMapViewport?: ActionHandler<typeof toggleSplitMapViewport>;
isViewportUnsyncAllowed?: boolean;
};

function MapControlPanelFactory() {
Expand All @@ -131,7 +132,8 @@ function MapControlPanelFactory() {
isExport,
logoComponent,
mapState,
onToggleSplitMapViewport
onToggleSplitMapViewport,
isViewportUnsyncAllowed
}) => {
const {isViewportSynced, isZoomLocked} = mapState || {};
const onUnlockViewportChange = useCallback(() => {
Expand All @@ -150,7 +152,7 @@ function MapControlPanelFactory() {
marginBottom: '8px !important'
}}
>
{mapState?.isSplit ? (
{mapState?.isSplit && isViewportUnsyncAllowed ? (
<StyledMapControlPanelHeaderSplitViewportsTools>
<StyledSBCenterFlexbox style={{paddingBottom: '6px'}}>
<FormattedMessage id="Unlock Viewport" />
Expand Down
10 changes: 9 additions & 1 deletion src/components/src/map/map-legend-panel.tsx
Expand Up @@ -36,6 +36,11 @@ import {ActionHandler, toggleSplitMapViewport} from '@kepler.gl/actions';

MapLegendPanelFactory.deps = [MapControlTooltipFactory, MapControlPanelFactory, MapLegendFactory];

export type MapLegendPanelFactoryDeps = [
typeof MapControlTooltipFactory,
typeof MapControlPanelFactory,
typeof MapLegendFactory
];
interface PinToBottomProps {
offsetRight?: number;
}
Expand Down Expand Up @@ -71,6 +76,7 @@ export type MapLegendPanelProps = {
mapHeight?: number;
offsetRight?: number;
onToggleSplitMapViewport?: ActionHandler<typeof toggleSplitMapViewport>;
isViewportUnsyncAllowed?: boolean;
};

function MapLegendPanelFactory(MapControlTooltip, MapControlPanel, MapLegend) {
Expand All @@ -89,7 +95,8 @@ function MapLegendPanelFactory(MapControlTooltip, MapControlPanel, MapLegend) {
mapState,
mapHeight,
offsetRight,
onToggleSplitMapViewport
onToggleSplitMapViewport,
isViewportUnsyncAllowed = true
}) => {
const mapLegend = mapControls?.mapLegend || ({} as MapControl);
const {active: isPinned} = mapLegend || {};
Expand Down Expand Up @@ -136,6 +143,7 @@ function MapLegendPanelFactory(MapControlTooltip, MapControlPanel, MapLegend) {
logoComponent={logoComponent}
mapState={mapState}
onToggleSplitMapViewport={onToggleSplitMapViewport}
isViewportUnsyncAllowed={isViewportUnsyncAllowed}
>
<MapLegend layers={layers} mapHeight={mapHeight} />
</MapControlPanel>
Expand Down
2 changes: 1 addition & 1 deletion src/reducers/src/map-state-updaters.ts
Expand Up @@ -324,7 +324,7 @@ export const toggleSplitMapViewportUpdater = (
state: MapState,
action: MapStateActions.ToggleSplitMapViewportUpdaterAction
) => {
// new map state immediately gets the new payload values for isViewportSynced and isZoomLocked
// new map state immediately gets the new, optional payload values for isViewportSynced and/or isZoomLocked
const newMapState = {
...state,
...(action.payload || {})
Expand Down

0 comments on commit 485252a

Please sign in to comment.