Responsive and javascript problem
-
I have two problems: I’d like to set the window into the center, but the script it throws on some resolutions sometimes in the right.
So is there a way to trigger custom script to set the window position?
Are there any callback to use it?
I tried following code:// Resize event for reposition jQuery(window).bind('resize orientationchange', function($) { if (document.getElementById('eModal-1')) { reposition(); } else return true; // Repositions the modal }); var reposition = function() { // Elements must be visible before height calculation //$('#eModal-1, #pgwModalBackdrop').show(); emodal_top(); var windowWidth = $(window).width(); var modalWidth = $('#eModal-1 .emodal-content').first().outerWidth(); var modalLeft = Math.round((windowWidth - modalWidth) / 2); $('#eModal-1').css('left',modalLeft); return true; } var emodal_top = function() { var windowHeight = $(window).height(); var modalHeight = $('#eModal-1').outerHeight(); var modalTop = Math.round((windowHeight - modalHeight) / 3); if (modalTop <= 0) { modalTop = 0; } $('#eModal-1').css('top', modalTop); } jQuery(function($){ $( "#call-me" ).click(function() { $('eModal-1').bind('emodalAfterOpen', function() { alert('Reposition');reposition(); }); });
How can I use the callback ’emodalAfterOpen’? Is this a correct way to set its custom position?
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘Responsive and javascript problem’ is closed to new replies.