I want to determine my ScreenViewport and then position of an element. And want to see if its present in 20% of the bottom of the window, or 20% top of the window.
I have two questions. First when I calculate viewport it returns 339
whereas the element offset returns 763
. How is element's offset greater than the viewport?
Second I want to know how can I get the 20% bottom and 20% top of the screen so I can match the offset with them
placement: function (context, source) {
var windowpos = $(window).height(); //339
var position = $(source).offset(); //top: 763
if(position.top < 20% of bottom of windowpos) {
return "bottom";
}
return "auto right";
}