Perspective Get View Canvas Instance Height

I’m building a vertical navigation scheme in perspective using a menu component and a view canvas. The idea is when you click on an item in the menu, the canvas will scroll to the desired position (something like this: Sticky Sidebar Navigation on Scroll – CodeMyUI). The way I’m accomplishing this now is by adding the height of each instance in the view up to the one I want to navigate to, and then setting the “top” property of each instance to that value (each instance is set to “relative” position).

Script is similar to this:

# Menu onActionPerformed Event
self.view.custom.selection_pos = event.path[0]

# canvas_top custom prop with script binding to selection_pos
self.custom.canvas_top = -1 * sum(instance[“height”] for instance in self.props.instances[:self.view.custom.selection_pos])

Everything is working like I want, but right now I have to set the height of each instance so that I can add them. I would prefer to leave the height on “auto”. I noticed that the View Canvas component has an event action onInstanceClicked, which you can use to get event.size.height, which will return the actual height of the instance, not just the “auto” string.

The question is, how can I get the actual instance height when it’s set to “auto” without having to manually click on each instance. My first thought was that these heights must be exposed somewhere, but it doesn’t seem like there is a function to access them directly. My next thought was to somehow call the onInstanceClicked event through scripting on each instance, but I can’t find a way to do this either. Any thoughts or ideas are greatly appreciated!

I found a different way to achieve the effect I am looking for without using a View Canvas, and the result is much cleaner! I didn’t realize you could use the domId meta property and system.perspective.navigate('#domId') to scroll to a position on the page, but now that I’ve figured that out, it made this whole thing much easier. Now the problem is keeping the navigation menu “docked” in the middle of the page, but I found a solution for this too, just took some playing around.

I would still like to be able to get component heights when they are set to auto, but its not entirely necessary now. It is very nice having the viewport dimensions available now though!