Skip to content

Commit

Permalink
fix b6ddf2a: scroll popup in mobile
Browse files Browse the repository at this point in the history
  • Loading branch information
tophf committed Sep 21, 2024
1 parent 5826e7e commit 708c187
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/popup/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { sendCmdDirectly } from '@/common';
import handlers from '@/common/handlers';
import { loadScriptIcon } from '@/common/load-script-icon';
import { mapEntry } from '@/common/object';
import { render } from '@/common/ui';
import { isTouch, render } from '@/common/ui';
import '@/common/ui/style';
import App from './views/app';
import { emptyStore, store } from './utils';
Expand Down Expand Up @@ -88,6 +88,8 @@ async function setPopup(data, { [kFrameId]: frameId, url }) {
if (!hPrev) {
hPrev = innerHeight;
window.onresize = onResize;
// Mobile browsers show the popup maximized to the entire screen, no resizing
if (isTouch && hPrev > document.body.clientHeight) onResize();
}
}

Expand Down Expand Up @@ -134,11 +136,12 @@ function isMyTab(tab) {
return tab && (!store.tab || store.tab.id === tab.id);
}

function onResize() {
function onResize(evt) {
// 1. Ignoring initial empty popup
// 2. Ignoring initial devicePixelRatio which is based on page zoom in this extension's tabs
const h = innerHeight;
if (h > hPrev && document.readyState !== 'loading' && document.body.clientHeight > h) {
if (!evt
|| h > hPrev && document.readyState !== 'loading' && document.body.clientHeight > h) {
window.onresize = null;
store.maxHeight = h + 'px';
}
Expand Down

0 comments on commit 708c187

Please sign in to comment.