L
L
lavezzi12015-12-01 18:44:18
css
lavezzi1, 2015-12-01 18:44:18

How to add a class so that the dropdown opens up\right\left if there is no space?

Hello! How is it implemented? Let's say there is a dropdown that opens down, if you scroll the page to it, it will open up (for example, the up class will be added).

Answer the question

In order to leave comments, you need to log in

2 answer(s)
Y
Yuri, 2015-12-01
@kapitan7830

You need to get the menu and scroll coordinates, get the dimensions of the dropdown menu, and check if it fits where you want it to.
https://learn.javascript.ru/metrics
https://learn.javascript.ru/metrics-window
https://learn.javascript.ru/coordinates
https://learn.javascript.ru/coordinates-document

V
vovastradamus, 2015-12-03
@vovastradamus

Before opening, you read all the coordinates (height/width of the dialog, position from the top/left of the page, page height, etc.), compare, add classes, and only then open the dialog.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question