• Resolved Jack

    (@jack1132132)


    I’ve tried everything, including editing the ./assets/js/um-functions.js and ./assets/js/um-functions.min.js files, but nothing seems to stop the body and html from scrolling when the modal is opened.

    Here’s what happens:


    THIS ONLY HAPPENS IN SAFARI

    Is there anyway to solve this? Thank you.

    • This topic was modified 2 years, 4 months ago by Jack.
Viewing 6 replies - 1 through 6 (of 6 total)
  • Thread Starter Jack

    (@jack1132132)

    SOLVED:

    Add to the files um-functions.js and um-function.min.js the following code:

    var $docEl = jQuery("body,html"),
        $wrap = jQuery('#wrap'),
        scrollTop;
    
    function overlayClose() {
        jQuery.unlockBody();
      }
    
    function overlayOpen() {
        jQuery.lockBody();
      }
    
      jQuery.lockBody = function() {
        if(window.pageYOffset) {
          scrollTop = window.pageYOffset;
          
          $wrap.css({
            top: - (scrollTop)
          });
        }
    
        $docEl.css({
          height: "100%",
          overflow: "hidden"
        });
      }
    
      jQuery.unlockBody = function() {
        $docEl.css({
          height: "",
          overflow: ""
        });
    
        $wrap.css({
          top: ''
        });
    
        window.scrollTo(0, scrollTop);
        window.setTimeout(function () {
          scrollTop = null;
        }, 0);
    
      }

    And add overlayClose() and overlayOpen() to the following functions:

    function remove_Modal() {
    	if ( jQuery('.um-popup-overlay').length ) {
    		wp.hooks.doAction( 'um_before_modal_removed', jQuery('.um-popup') );
    
    		jQuery('.tipsy').remove();
    		jQuery('.um-popup').empty().remove();
    		jQuery('.um-popup-overlay').empty().remove();
    		
    		overlayClose();
    	}
    }
    function um_remove_modal() {
    	jQuery('img.cropper-hidden').cropper('destroy');
    
    	overlayClose();
    	jQuery(document).unbind('touchmove');
    
    	jQuery('body > .um-modal div[id^="um_"]').hide().appendTo('body');
    	jQuery('body > .um-modal, body > .um-modal-overlay').remove();
    
    }
    function um_new_modal( id, size, isPhoto, source ) {
    	var modalOverlay = jQuery('.um-modal-overlay');
    	if ( modalOverlay.length !== 0 ) {
    		modalOverlay.hide();
    		modalOverlay.next('.um-modal').hide();
    	}
    
    	jQuery('.tipsy').hide();
    
    	UM.dropdown.hideAll();
    
    	overlayOpen();
    
    	jQuery( document ).bind( "touchmove", function(e){e.preventDefault();});
    	jQuery( '.um-modal' ).on('touchmove', function(e){e.stopPropagation();});
    
    	var $tpl = jQuery( '<div class="um-modal-overlay"></div><div class="um-modal"></div>' );
    	var $modal = $tpl.filter('.um-modal');
    	$modal.append( jQuery( '#' + id ) );
    
    	jQuery('body').append( $tpl );
    
    	if ( isPhoto ) {
    		var photo_ = jQuery('<img src="' + source + '" />'),
    			photo_maxw = jQuery(window).width() - 60,
    			photo_maxh = jQuery(window).height() - jQuery(window).height() * 0.25;
    
    		photo_.on( 'load', function() {
    			$modal.find('.um-modal-photo').html( photo_ );
    
    			$modal.addClass('is-photo').css({
    				'width': photo_.width(),
    				'margin-left': '-' + photo_.width() / 2 + 'px'
    			}).show().children().show();
    
    			photo_.css({
    				'opacity': 0,
    				'max-width': photo_maxw,
    				'max-height': photo_maxh
    			}).animate({'opacity' : 1}, 1000);
    
    			um_modal_responsive();
    		});
    	} else {
    
    		$modal.addClass('no-photo').show().children().show();
    
    		um_modal_size( size );
    
    		initImageUpload_UM( jQuery('.um-modal:visible .um-single-image-upload') );
    		initFileUpload_UM( jQuery('.um-modal:visible .um-single-file-upload') );
    
    		um_modal_responsive();
    
    	}
    
    }
    function prepare_Modal() {
    	if ( jQuery('.um-popup-overlay').length == 0 ) {
    		jQuery('body').append('<div class="um-popup-overlay"></div>');
    		jQuery('body').append('<div class="um-popup"></div>');
    		jQuery('.um-popup').addClass('loading');
    		
    		overlayOpen();
    
    	}
    }

    Now both in Safari iOS and any other browser the body will lock when the modal opens, and after the modal is closed the page will return to the same spot when the modal opened.

    • This reply was modified 2 years, 4 months ago by Jack.

    @jack1132132

    Will this solve your other issue here too?

    https://www.ads-software.com/support/topic/cropping-image-on-iphone-is-buggy/

    • This reply was modified 2 years, 4 months ago by missveronica.
    Thread Starter Jack

    (@jack1132132)

    Plugin Support Ultimate Member Support

    (@ultimatemembersupport)

    Hi @jack1132132

    Does this issue occur with a default WP Theme? What’s the theme are you using with this issue?

    Thread Starter Jack

    (@jack1132132)

    @ultimatemembersupport hello, yes it occurs with the default theme too.

    Has this issue been resolved in a new version?

    Thank you.

    • This reply was modified 2 years ago by Jack.
Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Safari doesn’t stop scrolling of html & body on opening modal!’ is closed to new replies.