reacting to the view : get new location #2411
Unanswered
MikeAxtell
asked this question in
Q&A
Replies: 1 comment 2 replies
-
The offsetPx and bpPerPx are fundamental internal state values that let us calculate what region is being viewed. But, in order to make it more useful, you can use "derived state". This is essentially a function that calculates a value based on the internal state If you are using React for your component, then you can say something like this
The VisibleRegions is a "observer" component, it observes the state of the view, and whenever coarseDynamicBlocks updates, it redraws a new text (there is dynamicBlocks and coarseDynamicBlocks, coarseDynamicBlocks is just throttled to update slightly less frequently e.g. every 250ms) |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I am playing with embedding a JBrowse2 linear genome view per https://jbrowse.org/jb2/docs/tutorials/embed_linear_genome_view/01_introduction/
What I would like to do is react to a change in the genome browser's location (I want each change in location to spawn a JQuery to get some data from server, based on location). Following the example at https://jbrowse.org/jb2/docs/tutorials/embed_linear_genome_view/08_reacting/
.. I am not seeing a clear "location" in the JSON patch data. None of the text sent by
seems to have the current location. For instance, on initial loading at location
Ccam0.32_scaffold14b:1,771,180..1,771,366
, the patch data reads:None of the above data actually contains the current location. If I zoom out to
Ccam0.32_scaffold14b:1,771,087..1,771,460
, the patch update says:again which does not give any information about the new location.
I wonder could someone give an example of how to listen for changes in the genome broswer's location (in Chr:start-stop format or something like that), preferably writing the new location to console.log?
Beta Was this translation helpful? Give feedback.
All reactions