popup: improve visibility checking algorithm
Merge pull request #733 from bem/imp-popup-visibility-check

popup: improve visibility checking algorithm