How to hide a dock view in desktop screen ,but show up in mobile screen

I would like to create a header dock view , it will hind in normal screen and show up in mobile screen. I would like to add a scrip in Startup of session event , but I don’t know how to catch up the window size , may I know if there is specific property so I could use it ?
Or any better suggestion to implement the functionality?

Thank you

1 Like

Hi @lili.zheng2010, I don’t think you will be able to do this as part of a Startup script in the session events as the session props will not be initialised until after the session starts. You will need the session.props.device.type property to determine what your device is.

One way you could possibly do it is to use a startup script on your docked view or the root container that determines which device is being used and then calls system.perspective.closeDock() to hide it if it’s a desktop. The only issue with this is you might see the animation of the docked view being closed as the session loads.

The other way to look at it is to open the docked view if it’s on a ios/android device. You can do this by doing something similar to the above but using the startup script on the main view (used as the startup page) and using openDock(). This provides a nicer animation IMO, as it looks like the dock window animation is part of the loading process. However, this all assumes you will always use the main view on session start.

Note you will not be able to use openDock() or closeDock() in Session Event Scripts as the functions are session scoped but the Event scripts are Gateway scoped.

Thank you for the details , glad to know that !

1 Like

This is incorrect. openDock and closeDock may indeed be used within Session Event scripts, though if my memory serves me it might not have been until later in the 8.0.X cycle that this was introduced.

Hi @cmallonee, apologies I did not realise this. It seems the documentation has not been updated yet (I assume it should also have Gateway in the scope option?). If so, could you flag this?

I don’t think Perspective functions should have Gateway scope included.

I suspect you’re getting hung-up due to this:
Note: Although they are designed to handle Session Events, the scripts that you write will be run in a Gateway scope, not a Session scope.

This was meant to clarify how Perspective Sessions work for users coming over from Vision without having used Perspective before. Many early users would try to use Client-scoped functions in Perspective Sessions because they thought of each session as a “Client”, when really the browser is just a portal and there is no “client”. It can be a little misleading, because EVERY Perspective script is run on the Gateway.

That makes sense, I had the same thought as I was reviewing my post. Thank you for the clarification. I understand that all perspective scripts run on the gateway. It’s just a little confusing on which run where.

It might be better to explicitly state it in the documentation :thinking: although I guess that would be a bit of a headache for the authors :sweat_smile: