What is a session?
A session is a way to define what the state of the view is. By providing a default session, you can have tracks already open when the view loads, have the overview hidden, or set any other aspect of the state.
If you provide "location" when constructing the view, it will override the location defined in the defaultSession.
What does a session look like?
To provide a default session, pass an object like this to
the view constructor:
So how do we get the view state?
Getting the view state
The state can be gotten by JSON stringifying the view's view attribute. We're going to add a button to our page that will show the current view state when clicked. Update "index.html" like this:
Now you can navigate around the view and then click "Show view state" to show the current state of the view. This object can be used in the "view" of the defaultSession to have the view show up in this state when loaded. Play around with the view and see what in the view state changes when you do certain things.
Some of the view state entries are:
bpPerPx- This is a zoom level. A smaller number is more zoomed in.
displayedRegions- The extent of the areas currently in view. By default it will be the full extent of a single chromosome, but you can add multiple regions, have the regions cover only part of a chromosome, reverse the regions, etc.
hideHeader- Whether or not the header is hidden.