@flowmap.gl/data 8.0.2 → 8.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@flowmap.gl/data",
3
- "version": "8.0.2",
3
+ "version": "8.0.3",
4
4
  "main": "dist/index.js",
5
5
  "module": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -41,7 +41,7 @@
41
41
  "@types/mapbox__geo-viewport": "^0.5.0",
42
42
  "@types/seedrandom": "^3.0.5"
43
43
  },
44
- "gitHead": "b55bad6919f236f7e38def565e27f231b9323e38",
44
+ "gitHead": "3b490dcf0cc2e0235f054b7205f8fa3eb23132d7",
45
45
  "publishConfig": {
46
46
  "access": "public"
47
47
  }
@@ -101,6 +101,10 @@ export default class FlowmapSelectors<
101
101
  };
102
102
  getMaxTopFlowsDisplayNum = (state: FlowmapState, props: FlowmapData<L, F>) =>
103
103
  state.settings.maxTopFlowsDisplayNum;
104
+ getFlowEndpointsInViewportMode = (
105
+ state: FlowmapState,
106
+ props: FlowmapData<L, F>,
107
+ ) => state.settings.flowEndpointsInViewportMode;
104
108
  getSelectedLocations = (state: FlowmapState, props: FlowmapData<L, F>) =>
105
109
  state.filter?.selectedLocations;
106
110
  getLocationFilterMode = (state: FlowmapState, props: FlowmapData<L, F>) =>
@@ -847,12 +851,14 @@ export default class FlowmapSelectors<
847
851
  this.getSelectedLocationsSet,
848
852
  this.getLocationFilterMode,
849
853
  this.getMaxTopFlowsDisplayNum,
854
+ this.getFlowEndpointsInViewportMode,
850
855
  (
851
856
  flows,
852
857
  locationIdsInViewport,
853
858
  selectedLocationsSet,
854
859
  locationFilterMode,
855
860
  maxTopFlowsDisplayNum,
861
+ flowEndpointsInViewportMode,
856
862
  ) => {
857
863
  if (!flows || !locationIdsInViewport) return undefined;
858
864
  const picked: (F | AggregateFlow)[] = [];
@@ -860,10 +866,13 @@ export default class FlowmapSelectors<
860
866
  for (const flow of flows) {
861
867
  const origin = this.accessors.getFlowOriginId(flow);
862
868
  const dest = this.accessors.getFlowDestId(flow);
863
- if (
864
- locationIdsInViewport.has(origin) ||
865
- locationIdsInViewport.has(dest)
866
- ) {
869
+ const originInView = locationIdsInViewport.has(origin);
870
+ const destInView = locationIdsInViewport.has(dest);
871
+ const isInViewport =
872
+ flowEndpointsInViewportMode === 'both'
873
+ ? originInView && destInView
874
+ : originInView || destInView;
875
+ if (isInViewport) {
867
876
  if (
868
877
  this.isFlowInSelection(
869
878
  flow,
@@ -6,6 +6,8 @@
6
6
 
7
7
  import {LocationFilterMode, ViewportProps} from './types';
8
8
 
9
+ export type FlowEndpointsInViewportMode = 'any' | 'both';
10
+
9
11
  export interface FilterState {
10
12
  selectedLocations?: (string | number)[];
11
13
  locationFilterMode?: LocationFilterMode;
@@ -28,6 +30,7 @@ export interface SettingsState {
28
30
  colorScheme: string | string[] | undefined;
29
31
  highlightColor: string;
30
32
  maxTopFlowsDisplayNum: number;
33
+ flowEndpointsInViewportMode: FlowEndpointsInViewportMode;
31
34
  }
32
35
 
33
36
  export interface FlowmapState {