Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

enable scrolling locally, but keep disabled in iframe #43

Merged
merged 9 commits into from
Feb 7, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
dist: focal
language: node_js
node_js:
- v20.13.1
cache:
directories:
- node_modules
before_install:
- npm i -g [email protected]
install:
- npm install
script:
- npm run build
1 change: 1 addition & 0 deletions components/iframeCommunication.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ const IframeCommunication = () => {
}, 50);
}
};


useEffect(() => {
// Send initial page height and path
Expand Down
22 changes: 18 additions & 4 deletions pages/_app.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,21 @@
import '../styles.css'
import { useEffect } from 'react';
import '../styles.css';
import IframeCommunication from '../components/iframeCommunication';

// This default export is required in a new `pages/_app.js` file.

export default function MyApp({ Component, pageProps }) {
return <><IframeCommunication /><Component {...pageProps} /></>;
useEffect(() => {
if (typeof window === 'undefined') return;
if (window.self !== window.top) {
document.body.classList.add("in-iframe");
} else {
document.body.classList.remove("in-iframe");
}
}, []);

return (
<>
<IframeCommunication />
<Component {...pageProps} />
</>
);
}
40 changes: 39 additions & 1 deletion styles.css
Original file line number Diff line number Diff line change
@@ -1,5 +1,43 @@
html, body {
height: 100vh;
max-height: 100vh;
overflow: hidden;
}

body {
font-family: 'SF Pro Text', 'SF Pro Icons', 'Helvetica Neue', 'Helvetica',
'Arial', sans-serif;
overflow-y: hidden;
}
}

body:not(.in-iframe) {
overflow-y: auto;
}

.main-content {
flex: 1;
height: 100%;
max-height: 100vh;
overflow-y: auto; /* Zorgt ervoor dat de inhoud in de iframe kan scrollen */
padding: 20px;
background: white;
}

iframe {
width: 100%;
height: 100vh !important; /* Zorgt dat de iframe altijd de volle hoogte krijgt */
overflow-y: auto !important; /* Voorkomt dat de iframe-inhoud wordt afgesneden */
border: none;
}

body.in-iframe {
overflow-y: auto !important;
height: auto !important;
max-height: 100vh !important;
}

body.in-iframe .main-content {
overflow-y: auto !important;
height: auto !important;
max-height: 100vh !important;
}
Loading