How to detect which side a selectmenu will open at? (Solved)

How to detect which side a selectmenu will open at? (Solved)

I'm using selectmenu widget. And I'm setting the collision to "flip" because I want to flip the selectmenu to the opposite side when there is not enough space below the trigger.

The code is like:
  1. $('#my-select').selectmenu({
        position : { my: 'left top', at: 'left bottom', collision: 'flip' },
        ......
    });


And when the selectmenu is flipped to the opposite side, I need to apply a slightly different style on it to make it look well with the trigger.

I checked the class names of the selectmenu and didn't find any difference between the non-flipped and flipped versions.

So my question is that, before a selecemenu is about to open, how do I detect that it will open at the opposite side?