1
 Follower
1
 Like

Get screen width and height

Frontend
Not right now

There is already a way to get this with a workaround with javascript

1. get and set the parameters in vars

2. notify it using the 'OsNotifyWidget' in javascript with the id of a fakenotify webblock

3. in the on notify, use notifyGetMessage()

4. assign the width/height  to a variable in outsystems you wish to use it for

5. refresh the block that is to use that variable.


Would it be possible to have some kind of property that will be filled on run time with the pagewidth/pageheight? So that we can build the logic around that variable?


I used this to have a page width based Gallery structure as in the attached picture

 Structure-Gallery-PageWidth.PNG
Created on 2 May
Comments (7)

What would be different than your workaround?

Issue here is, the browser sends a request to get a page. In the first request there is, afaik, still no information on the width/height. So you always need to generate the webpage first, run javascript to check and pass that back to the server.



Changed the category to Frontend


I agree it may be trivial to have such a parameter as this workaround works well. I was thinking about the CSS units  width of the viewport and height of the viewport. You can do alot with them in css, but they are not supported as inputs to elements on the widget tree


err,


could you explain what you do mean then?

Not sure if I understand it correctly?


Take for example the popup_editor. You can define the width and the height of the popup, or allow the popup editor script to resize the popup automatically. 


We have seen on some smaller screens that the popup editor does not correctly scale the popup height or width. So we wanted to define the height/width of the popup based on the screen size for those smaller screens. Basically defining a width of 85vw.  Since we cannot do that, we used the get page width/height javascript method to definee the popup width/height


I hope this clarifies more where I was getting at,


Cheers

Shahin,


You cannot include logic in the Preparation of a WebScreen based on, say, the screen height and width because the server-end does not have access to window information.


I figure your problem is more specific to the Popup_Editor widget from RichWidgets. You could try copying the Popup_Editor Web Block onto your project and modifying it so it can accept the vw unit in the width/height parameters.

Changed the status to
Not right now


Hey Shahin,

As Caio referred, to provide the page view as a variable we would have to render the page server side to understand its size.

I would suggest to use SILK's modal widget or trying to create that style using css (rather than using it as low code logic).

Since we have workarounds, we don't have this in our short/mid term roadmap.

Cheers and thanks for your contribution

views
337
Followers
1