mirror of https://github.com/gorhill/uBlock.git
complete fix to #2274: detect device rotation
This commit is contained in:
parent
35a63c784f
commit
e5f435c3b1
|
@ -478,6 +478,8 @@ var renderPopup = function() {
|
||||||
// All rendering code which need to be executed only once.
|
// All rendering code which need to be executed only once.
|
||||||
|
|
||||||
var renderOnce = function() {
|
var renderOnce = function() {
|
||||||
|
renderOnce = function(){};
|
||||||
|
|
||||||
if ( popupData.fontSize !== popupFontSize ) {
|
if ( popupData.fontSize !== popupFontSize ) {
|
||||||
popupFontSize = popupData.fontSize;
|
popupFontSize = popupData.fontSize;
|
||||||
if ( popupFontSize !== 'unset' ) {
|
if ( popupFontSize !== 'unset' ) {
|
||||||
|
@ -492,27 +494,35 @@ var renderOnce = function() {
|
||||||
uDom.nodeFromId('appname').textContent = popupData.appName;
|
uDom.nodeFromId('appname').textContent = popupData.appName;
|
||||||
uDom.nodeFromId('version').textContent = popupData.appVersion;
|
uDom.nodeFromId('version').textContent = popupData.appVersion;
|
||||||
|
|
||||||
|
// For large displays: we do not want the left pane -- optional and
|
||||||
|
// hidden by defaut -- to dictate the height of the popup. The right pane
|
||||||
|
// dictates the height of the popup, and the left pane will have a
|
||||||
|
// scrollbar if ever its height is more than what is available.
|
||||||
|
// For small displays: we use the whole viewport.
|
||||||
|
|
||||||
var rpane = uDom.nodeFromSelector('#panes > div:first-of-type'),
|
var rpane = uDom.nodeFromSelector('#panes > div:first-of-type'),
|
||||||
lpane = uDom.nodeFromSelector('#panes > div:last-of-type');
|
lpane = uDom.nodeFromSelector('#panes > div:last-of-type');
|
||||||
|
|
||||||
// I do not want the left pane -- optional and hidden by defaut -- to
|
var fillViewport = function() {
|
||||||
// dictate the height of the popup. The right pane dictates the height
|
lpane.style.setProperty(
|
||||||
// of the popup, and the left pane will have a scrollbar if ever its
|
'height',
|
||||||
// height is more than what is available.
|
Math.max(
|
||||||
var lpaneHeight = rpane.offsetHeight;
|
window.innerHeight - uDom.nodeFromSelector('#gotoPrefs').offsetHeight,
|
||||||
|
rpane.offsetHeight
|
||||||
|
) + 'px'
|
||||||
|
);
|
||||||
|
lpane.style.setProperty('width', (window.innerWidth - rpane.offsetWidth) + 'px');
|
||||||
|
};
|
||||||
|
|
||||||
// https://github.com/gorhill/uBlock/issues/2274
|
// https://github.com/gorhill/uBlock/issues/2274
|
||||||
// Make use of the whole viewport on mobile devices.
|
// Make use of the whole viewport on mobile devices.
|
||||||
if ( document.body.classList.contains('mobile') ) {
|
if ( document.body.classList.contains('mobile') ) {
|
||||||
lpaneHeight = Math.max(
|
fillViewport();
|
||||||
window.innerHeight - uDom.nodeFromSelector('#gotoPrefs').offsetHeight,
|
window.addEventListener('resize', fillViewport);
|
||||||
lpaneHeight
|
return;
|
||||||
);
|
|
||||||
lpane.style.setProperty('width', (window.innerWidth - rpane.offsetWidth) + 'px');
|
|
||||||
}
|
}
|
||||||
lpane.style.setProperty('height', lpaneHeight + 'px');
|
|
||||||
|
|
||||||
renderOnce = function(){};
|
lpane.style.setProperty('height', rpane.offsetHeight + 'px');
|
||||||
};
|
};
|
||||||
|
|
||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
|
|
Loading…
Reference in New Issue