gosling.js
gosling.js copied to clipboard
How to force rerendering gosling component when reactive is set to true
One limitation depending on your use case might be that upon the resize, the zoom level is unchanged, instead, the xDomain is changed to show/hide left- and right-most area, which is the fixed behavior in HiGlass. reference #528
I want to force rerendering to work around the limitation of the zoom level being unchanged. How can I issue a rerendering?
Zhen
Hi Zhen,
The HiGlass' default behavior that maintains the zoom level and the center position would need to be changed, which is defined around the following line of code:
https://github.com/higlass/higlass/blob/0299ae1229fb57e0ca8da31dff58003c3e5bf1cf/app/scripts/TrackRenderer.js#L683
A workaround I can think of for now (other than editing the above code) is turning off the experimental.reactive
flag, but I think this does not work for you since you are using this flag.
A workaround I can think of for now (other than editing the above code) is turning off the
experimental.reactive
flag, but I think this does not work for you since you are using this flag.
I want to call the api.zoomTo() function to achieve this. But the return of calling the api.getViewIds() function is an empty list in the useEffect. I suspect that tracks are not available at the time of calling this function.
Yes, it looks so. I have not used this approach before so not sure if the use of api.zoomTo()
will work well for your use case. This is not a solid way, but you could try waiting for a few (heuristically determined) milliseconds upon compilation (i.e., <GoslingComponent ref=gosRef} ... compiled={(g, h) => { /* do something */ }/>
) or useEffect
of gosRef
.