lanl / 4DGB

4D Genome Browser project
1 stars 2 forks source link

Allow saving & restoring of Selection through URL parameters. #80

Closed camtauxe closed 2 years ago

camtauxe commented 2 years ago

This commit allows for saving and restoring a selection via URL parameters. The ControlPanel has gained a "permalink" button which displays a URL with the saved selection as a parameter (the Selection is saved as JSON then base64url encoded). When the main script (compare.js) loads, it will check the URL for such a parameter and, if it finds one, trigger on update on the Selection controller with it.

Because this happens when the page first loads, it's most likely that the other components haven't finished loading and thus, can't have their selections set. To fix this, both ContactMapCanvas and GeometryCanvas have been modifed to allow for 'selectionChanged' events before loading has finished. They will remember the event, and re-trigger it as soon as loading finishes. Triggering multiple 'selectionChanged' events before loading finishes, means that the only the most recent call will be the one that's triggered. The other events are discarded.