@@ -26,6 +26,23 @@ define( [
2626//>>excludeEnd("jqmBuildExclude");
2727( function ( $ , undefined ) {
2828
29+ function pointInRectangle ( x , y , windowCoordinates ) {
30+ return ( x >= windowCoordinates . x && x <= windowCoordinates . x + windowCoordinates . cx &&
31+ y >= windowCoordinates . y && y <= windowCoordinates . y + windowCoordinates . cy ) ;
32+ }
33+
34+ function isOutOfSight ( element , windowCoordinates ) {
35+ var offset = element . offset ( ) ,
36+ width = element . outerWidth ( true ) ,
37+ height = element . outerHeight ( true ) ;
38+
39+ return ! (
40+ pointInRectangle ( offset . left , offset . top , windowCoordinates ) ||
41+ pointInRectangle ( offset . left + width , offset . top , windowCoordinates ) ||
42+ pointInRectangle ( offset . left + width , offset . top + height , windowCoordinates ) ||
43+ pointInRectangle ( offset . left , offset . top + height , windowCoordinates ) ) ;
44+ }
45+
2946function fitSegmentInsideSegment ( windowSize , segmentSize , offset , desired ) {
3047 var returnValue = desired ;
3148
@@ -267,8 +284,10 @@ $.widget( "mobile.popup", {
267284
268285 _handleWindowResize : function ( /* theEvent */ ) {
269286 if ( this . _isOpen && this . _ignoreResizeTo === 0 ) {
270- if ( ( this . _expectResizeEvent ( ) || this . _orientationchangeInProgress ) &&
287+ if ( isOutOfSight ( this . _ui . container , getWindowCoordinates ( this . window ) ) &&
288+ ( this . _expectResizeEvent ( ) || this . _orientationchangeInProgress ) &&
271289 ! this . _ui . container . hasClass ( "ui-popup-hidden" ) ) {
290+
272291 // effectively rapid-close the popup while leaving the screen intact
273292 this . _ui . container
274293 . addClass ( "ui-popup-hidden ui-popup-truncate" )
0 commit comments