@abi-software/flatmap-viewer 2.2.8 → 2.2.9

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/README.rst CHANGED
@@ -38,7 +38,7 @@ The map server endpoint is specified as ``MAP_ENDPOINT`` in ``src/main.js``. It
38
38
  Package Installation
39
39
  ====================
40
40
 
41
- * ``npm install @abi-software/flatmap-viewer@2.2.8``
41
+ * ``npm install @abi-software/flatmap-viewer@2.2.9``
42
42
 
43
43
  Documentation
44
44
  -------------
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abi-software/flatmap-viewer",
3
- "version": "2.2.8",
3
+ "version": "2.2.9",
4
4
  "description": "Flatmap viewer using Maplibre GL",
5
5
  "repository": "https://github.com/AnatomicMaps/flatmap-viewer.git",
6
6
  "main": "src/main.js",
@@ -42,6 +42,7 @@ import {PathControl} from './controls.js';
42
42
  import {SearchControl} from './search.js';
43
43
  import {VECTOR_TILES_SOURCE} from './styling.js';
44
44
 
45
+ import * as pathways from './pathways.js';
45
46
  import * as utils from './utils.js';
46
47
 
47
48
  //==============================================================================
@@ -842,31 +843,34 @@ export class UserInteractions
842
843
  selectionEvent_(event, feature)
843
844
  //=============================
844
845
  {
845
- const multipleSelect = event.ctrlKey || event.metaKey;
846
- if (!multipleSelect) {
847
- this.__unselectFeatures();
848
- }
849
846
  if (feature !== undefined) {
850
- const featureId = feature.id;
851
- const selecting = !this.featureSelected_(featureId);
852
- if ('properties' in feature
853
- && 'type' in feature.properties
854
- && feature.properties.type.startsWith('line')) {
847
+ const clickedFeatureId = feature.id;
848
+ const dim = !('properties' in feature
849
+ && 'kind' in feature.properties
850
+ && ['cell-type', 'scaffold', 'tissue'].indexOf(feature.properties.kind) >= 0);
851
+ if (!(event.ctrlKey || event.metaKey)) {
852
+ let selecting = true;
853
+ for (const featureId of this._selectedFeatureIds.keys()) {
854
+ if (featureId === clickedFeatureId) {
855
+ selecting = false;
856
+ break;
857
+ }
858
+ }
859
+ this.__unselectFeatures();
860
+ if (selecting) {
861
+ for (const feature of this._activeFeatures) {
862
+ this.selectFeature_(feature.id, dim);
863
+ }
864
+ }
865
+ } else {
866
+ const clickedSelected = this.featureSelected_(clickedFeatureId);
855
867
  for (const feature of this._activeFeatures) {
856
- const featureId = feature.id;
857
- if (selecting) {
858
- this.selectFeature_(featureId);
868
+ if (clickedSelected) {
869
+ this.unselectFeature_(feature.id);
859
870
  } else {
860
- this.unselectFeature_(featureId);
871
+ this.selectFeature_(feature.id, dim);
861
872
  }
862
873
  }
863
- } else if (selecting) {
864
- const dim = !('properties' in feature
865
- && 'kind' in feature.properties
866
- && ['cell-type', 'scaffold', 'tissue'].indexOf(feature.properties.kind) >= 0);
867
- this.selectFeature_(featureId, dim);
868
- } else {
869
- this.unselectFeature_(featureId);
870
874
  }
871
875
  }
872
876
  }
@@ -875,24 +879,14 @@ export class UserInteractions
875
879
  //================
876
880
  {
877
881
  this.clearActiveMarker_();
878
- const clickedFeatures = this._map.queryRenderedFeatures(event.point)
879
- .filter(feature => this.__enabledFeature(feature));
882
+ const clickedFeatures = this._map.queryRenderedFeatures(event.point);
880
883
  if (clickedFeatures.length == 0){
884
+ this.__unselectFeatures();
881
885
  return;
882
886
  }
883
887
  const clickedFeature = clickedFeatures[0];
884
888
  const originalEvent = event.originalEvent;
885
- if (clickedFeature === undefined || this._activeFeatures.length === 1) {
886
- this.selectionEvent_(originalEvent, clickedFeature);
887
- } else if (this._activeFeatures.length > 1) {
888
- const multipleSelect = originalEvent.ctrlKey || originalEvent.metaKey;
889
- if (!multipleSelect) {
890
- this.__unselectFeatures();
891
- }
892
- for (const feature of this._activeFeatures) {
893
- this.selectFeature_(feature.id);
894
- }
895
- }
889
+ this.selectionEvent_(originalEvent, clickedFeature);
896
890
  if (this._modal) {
897
891
  // Remove tooltip, reset active features, etc
898
892
  this.__resetFeatureDisplay();
@@ -976,18 +970,23 @@ export class UserInteractions
976
970
  //===============================
977
971
  {
978
972
  // Disable/enable all paths except those with `pathTypes`
979
-
980
- this.enablePathFeatures_(!enable, this._pathways.allFeatureIds());
981
-
982
973
  if (Array.isArray(pathTypes)) {
983
- for (const pathType of pathTypes) {
984
- this.enablePath(pathType, enable);
974
+ for (const pathType of pathways.PATH_TYPES) {
975
+ if (pathTypes.indexOf(pathType.type) >= 0) {
976
+ this.enablePath(pathType.type, enable)
977
+ } else {
978
+ this.enablePath(pathType.type, !enable)
979
+ }
985
980
  }
986
981
  } else {
987
- this.enablePath(pathTypes, enable);
982
+ for (const pathType of pathways.PATH_TYPES) {
983
+ if (pathType.type === pathTypes) {
984
+ this.enablePath(pathType.type, enable)
985
+ } else {
986
+ this.enablePath(pathType.type, !enable)
987
+ }
988
+ }
988
989
  }
989
-
990
- this._disabledPathFeatures = true;
991
990
  }
992
991
 
993
992
  pathwaysFeatureIds(externalIds)