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

add scaling to <iframe>s in the preview list so all content can be seen #37

Merged
merged 4 commits into from
Aug 27, 2021
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
Binary file modified .github/images/greenwood-starter-presentation.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
46 changes: 24 additions & 22 deletions src/components/slide-list.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ class SlideList extends LitElement {
};
}

// TODO preserve aspect ratio
static get styles() {
return css`
:host {
Expand All @@ -34,20 +33,11 @@ class SlideList extends LitElement {
z-index: 100;
}

/* iframe {
height: 200px;
width: 10%;
margin-left: 15px;
margin-top: -10px;
transform: scale(1.5);
transform-origin: 0 0;
} */

span.num {
float: left
}

#wrap {
.wrap {
width: 100%;
padding: 0;
filter: drop-shadow(5px 10px 3px gray);
Expand All @@ -56,26 +46,19 @@ class SlideList extends LitElement {
position: relative;
}

#wrap > iframe {
.wrap > iframe {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
zoom: 0.75;
-moz-transform: scale(0.75);
-moz-transform-origin: 0 0;
-o-transform: scale(0.75);
-o-transform-origin: 0 0;
-webkit-transform: scale(0.75);
-webkit-transform-origin: 0 0;
}

@media screen and (-webkit-min-device-pixel-ratio: 0) {
#scaled-frame {
zoom: 1;
}
}
`;
}

Expand All @@ -97,6 +80,19 @@ class SlideList extends LitElement {
document.dispatchEvent(new CustomEvent('slide-selected', { detail: slide }));
}

slideLoaded(slide) {
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The only slight downside with this approach is that it causes the scaling to "snap" into place which may be somewhat noticeable.

But, if we apply this style directly the template, then it will also be scaled down in the main window too... so 🤷‍♂️

const frame = this.shadowRoot.getElementById(`slide_${slide.id}`);
const style = document.createElement('style');

style.textContent = `
body {
zoom: .4;
}
`;

frame.contentDocument.head.appendChild(style);
}

render() {
const { slides } = this;
const list = slides.map((slide, index) => {
Expand All @@ -105,8 +101,14 @@ class SlideList extends LitElement {
return html`
<span class="num">${slideNum})</span>
<div @click="${() => this.slideSelected(slide)}">
<div id="wrap">
<iframe id="scaled-frame" src="${slide.route}" loading="lazy"></iframe>
<div class="wrap">
<iframe
id="slide_${slide.id}"
src="${slide.route}"
class="scaled-frame"
@load="${() => this.slideLoaded(slide) }"
loading="lazy">
</iframe>
</div>
<div class="iframe-screen"></div>
</div>
Expand All @@ -119,4 +121,4 @@ class SlideList extends LitElement {
}
}

customElements.define('slide-list', SlideList);
customElements.define('slide-list', SlideList);
4 changes: 2 additions & 2 deletions src/layouts/theme-statement.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
div#container {
display: flex;
flex-direction: column;
justify-content: flex-end;
height: 90vh;
text-align: left;
height: 95vh;
padding-left: 2rem;
width: 100%;
margin: 0;
Expand Down