I have this JS function which centers everything on the page. This is called at the start of the page and automaticly centers when the window is resized.
I need a way to make the function not center anything when the web page is loaded on a mobile device.
/**
* This method centers a DOM element vertically and horizontally
* on the page.
*
* @param {object} elementHandle The object that is going to be
* centered.
*/
centerElementOnPage: function(elementHandle) {
// Center main frame vertical middle
$(window).resize(function() {
var elementLeft = ($(window).width() - elementHandle.outerWidth()) / 2;
var elementTop = ($(window).height() - elementHandle.outerHeight()) / 2;
elementTop = (elementTop > 0 ) ? elementTop : 20;
elementHandle.css({
position: 'absolute',
left: elementLeft,
top: elementTop
});
});
$(window).resize();
},
Edit :
Thanks for the css . The JS was messing up some other aspects of the page , so the css helps.