Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

All the zooms #886

Merged
merged 22 commits into from
Feb 5, 2020
Merged

All the zooms #886

merged 22 commits into from
Feb 5, 2020

Conversation

jameshadfield
Copy link
Member

PR representing #870 + #861 + bugfixes. See previous PRs for discussion.

@jameshadfield jameshadfield temporarily deployed to auspice-all-the-zooms-ygdha54l February 4, 2020 22:17 Inactive
@jameshadfield jameshadfield temporarily deployed to auspice-all-the-zooms-ygdha54l February 4, 2020 22:35 Inactive
@jameshadfield jameshadfield temporarily deployed to auspice-all-the-zooms-ygdha54l February 4, 2020 23:28 Inactive
@emmahodcroft
Copy link
Member

narrative-zoom-zoom
Example of the awesome narrative stuff we can do with these additions!!

emmahodcroft and others added 22 commits February 5, 2020 13:05
A bug in `createStateFromQueryOrJSONs` caused the color scale to be recreated unnecessarily on each page change in a narrative. This was somewhat harmless, but meant that the map logic was confusing as it would tend to remove D3 elements & recreate them unnecessarily (as it detected a color-by change), which was different to the expected behavior outside of narratives.
`maybeDrawDemes...` doesn't need to be called - all we need to do is change the map bounds without recomputing / redrawing any d3 elements
The previous implementation did not work on a lot of datasets (`demeIndices` and `demeData` seem to cause a lot of issues).

This commit breaks out the logic into a method `moveMapAccordingToData` which can be called from various places according to the react updates taking place. This is also the only place where the map is moved except for (a) the RESET ZOOM button and (b) when the user pans / zooms.

Effects:
* Loading a dataset with filters enabled zooms to the filtered data
* Narratives: changing filters between pages causes map zoom
* Narratives: changing geo res between pages causes map zoom

Also adds a number of console logs which should be cleaned up before release.
Already in narrative mode, if filters are enabled or geoRes changes, the map updates to fit the data in the screen. They weren't implemented for normal view, as moving the map can be annoying when you are interacting with the data.

Here we keep track of if a user has panned / zoomed the map at all (and this is reset upon pressing the "RESET ZOOM" button). If they are yet to interact with the map, then we do manipulate it when the filters (etc) change.

Note that clicking on the animation button "counts" as a user interaction. This avoids us constantly resizing the map during animation.
We need to run the `updateOnMoveEnd` function when the map loads, in order to correctly translate the d3elements. Due to a race condition, this wasn't being run for ebola -- potentially because the dataset wasn't drawn until after the map was ready?
If a user is yet to interact w. the map, then it will automagically zoom according to geo-res changes, filter changes etc. Clicking the "reset zoom" button now also resets the "user has interacted with map?" state (which was the original intention).
This shifts the code usage to mirror the intended URL query. By removing all old references to `query.clade` we reduce potential confusion. By keeping a string type for `<key>:<value>` we simplify the code and keep it in sync with the mental model for how the URL query looks. These changes also allow zooming to root in narratives when no label (clade) is specified in the URL.
Expected behavior:
(1) By default, "clade" will be shown, if present in the tree.
(2) If a JSON defines `branch_label` in the `display_defaults`, then this becomes the default shown in auspice.
(3) if a URL query `branchLabel` is set, this changes the current view.
a bug was found where the docstring described the original intention, but the code was doing something else. Updated the calling functions & docstrings to match what the code does. No change in behavior.
Errors were happening because the function was not being given the `dispatch` function. Dispatch is used to trigger notification banners (in this case). In future we should consider `createStateFromQueryOrJSONs` returning any errors / warnings to be handled higher up.
This was infrequently used in the past to trigger a zoom-to-root in the tree. This behavior now occurs if you simply do not provide a clade / label query key. To avoid unnecessary warning notifications we deal with this here.
Narratives which were zoomed into a part of the tree were liable to lose this zoom when not showing then reshowing a tree -- this is because the zoom setting wasn't always being applied to the tree when it was set up.
@jameshadfield jameshadfield temporarily deployed to auspice-all-the-zooms-ygdha54l February 5, 2020 00:24 Inactive
@jameshadfield
Copy link
Member Author

Merging this after a lot of testing by @emmahodcroft and myself.

@jameshadfield jameshadfield merged commit 154f5f5 into master Feb 5, 2020
@jameshadfield jameshadfield deleted the all-the-zooms branch February 5, 2020 03:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants