gosling.js icon indicating copy to clipboard operation
gosling.js copied to clipboard

How to force rerendering gosling component when reactive is set to true

Open zhangzhen opened this issue 2 years ago • 3 comments

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

zhangzhen avatar Nov 03 '21 07:11 zhangzhen

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.

sehilyi avatar Nov 03 '21 18:11 sehilyi

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.

zhangzhen avatar Nov 04 '21 02:11 zhangzhen

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.

sehilyi avatar Nov 08 '21 15:11 sehilyi