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

Possible scheduleRerender() needed to redraw non-transcript track? #1

Open
alexpreynolds opened this issue Sep 28, 2020 · 0 comments
Open

Comments

@alexpreynolds
Copy link
Contributor

Testing this track, it seems to work pretty well! I have run into a couple issues, which I'm documenting here in case they point to some issue.

In one test setup of my single-page web application, its viewconf has four tracks. The second track is a horizontal-multivec track and the fourth track is a horizontal-transcripts track, via the higlass-transcripts plugin.

Within the web application, I have the transcripts track object subscribe to the trackDimensionsModified event to get the new transcript track height whenever switching between "collapsed" and "all-transcripts-visible" modes:

setTimeout(() => {
  const self = this;
  const transcriptsTrackObj = this.mainHgView.api.getComponent().getTrackObject(
     res.data.views[0].uid,
     res.data.views[0].tracks.top[3].uid,
  );
  transcriptsTrackObj.pubSub.subscribe("trackDimensionsModified", (msg) => { 
    self.setState({
      transcriptsTrackHeight: parseInt(transcriptsTrackObj.trackHeight), // <-- get transcript track height
    }, () => {
      self.updateViewportDimensions(); // <-- recalculate multivec track height
    });
  });
}, 500);

The updateViewportDimensions() generates a viewconf with correct dimensions for all tracks. But the multivec track has the wrong (old) height. It does not redraw itself with the correct (new) height, until I manually pan or zoom the parent HiGlass view.

As a workaround, in order to get the multivec track to redraw, I called scheduleRerender() on that track.

In this modified call, the chromatinStateTrackObj variable refers to the multivec track whose height needs to be adjusted:

setTimeout(() => {
  const self = this;
  const chromatinStateTrackObj = this.mainHgView.api.getComponent().getTrackObject(
     res.data.views[0].uid,
     res.data.views[0].tracks.top[1].uid,
  );
  const transcriptsTrackObj = this.mainHgView.api.getComponent().getTrackObject(
     res.data.views[0].uid,
     res.data.views[0].tracks.top[3].uid,
  );
  transcriptsTrackObj.pubSub.subscribe("trackDimensionsModified", (msg) => { 
    self.setState({
      transcriptsTrackHeight: parseInt(transcriptsTrackObj.trackHeight), // <-- get transcript track height
    }, () => {
      self.updateViewportDimensions(); // <-- recalculate multivec track height
      chromatinStateTrackObj.scheduleRerender(); // <-- redraw the multivec track
    });
  });
}, 500);

Using scheduleRerender() seems to "refresh" the multivec track, so that it renders with the height value specified in the parent viewconf.

I'm not sure if this is a bug, or if I am not using the plugin correctly. I can provide a link to the development site separately (via Slack etc.) if it is helpful to see the issue firsthand.

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

No branches or pull requests

1 participant