-
Notifications
You must be signed in to change notification settings - Fork 699
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
Stretchy HTML5 iframe height #6663
Conversation
…der the iframe content to the HTML5 renderer.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
will test soon - just a quick review of the code itself
kolibri/plugins/html5_viewer/assets/src/views/Html5AppRendererIndex.vue
Outdated
Show resolved
Hide resolved
@@ -114,7 +123,8 @@ | |||
|
|||
.html5-renderer { | |||
position: relative; | |||
height: 500px; | |||
min-height: 500px; | |||
max-height: 70vh; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
vh
has mediocre support on older iOS and Android devices.
We can do this, but if there is a way to avoid vh
that would be preferable.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any ideas on alternatives? Doing percentage would make it relative to parent element, rather than expanding the height based on available screen space, wouldn't it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll take a look when I actually test it locally
let self = this; | ||
window.addEventListener('DOMContentLoaded', function() { | ||
const data = { | ||
offsetHeight: window.document.body.offsetHeight, | ||
}; | ||
const event = events.CONTENTLOADED; | ||
self.mediator.sendMessage({ nameSpace, event: event, data: data }); | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this file packaged with Webpack, or is it unprocessed because it gets embedded in Hashi?
If the former, you can use an arrow function here:
let self = this; | |
window.addEventListener('DOMContentLoaded', function() { | |
const data = { | |
offsetHeight: window.document.body.offsetHeight, | |
}; | |
const event = events.CONTENTLOADED; | |
self.mediator.sendMessage({ nameSpace, event: event, data: data }); | |
}); | |
window.addEventListener('DOMContentLoaded', () => { | |
const data = { | |
offsetHeight: window.document.body.offsetHeight, | |
}; | |
const event = events.CONTENTLOADED; | |
this.mediator.sendMessage({ nameSpace, event: event, data: data }); | |
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's packaged, I'll make the change! Didn't realize this got around the self = this problem.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yup - super convenient!
ref: https://hackernoon.com/javascript-es6-arrow-functions-and-lexical-this-f2a3e2a5e8c4
let self = this; | ||
this.hashi.on(events.CONTENTLOADED, function(data) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let self = this;
not necessary if you use an arrow function:
let self = this; | |
this.hashi.on(events.CONTENTLOADED, function(data) { | |
this.hashi.on(events.CONTENTLOADED, (data) => { |
// will not lead to problematic rendering scenarios. Consequently, this also means that it is only | ||
// giving us the ability to stretch at most a couple hundred pixels height-wise. | ||
if (data.offsetHeight && data.offsetHeight > 0) { | ||
self.$refs.html5Renderer.$refs.fullscreen.style.height = data.offsetHeight + 'px'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
rather than using nested $refs
and modifying .style.height
, it would be a bit more conventional to add a prop to CoreFullscreen
and pass in a height
if possible.
For example:
<template>
<div
ref="fullscreen"
:class="fullscreenClass"
:style="{ height: `${height} px` }"
allowfullscreen
>
<slot></slot>
</div>
</template>
<script>
// ...
props: {
height: { type: Number, required: false },
}
// ...
I've been experimenting with this a bit on different content and seeing some odd results. In For other content such as PraDigi and HP Life, the iframe doesn't resize at all, presumably because the content is rendered after the My recommendation would be to something like:
|
There are too many cases to handle fully dynamic sizing, I think. There are a number of different layout strategies a page may use:
The problem is that the only way to know for sure which it is would be to check the code. Polling and resizing every second will lead to recursion for cases 2 and sometimes 3 and 5, because we have no idea how the content responds to size changes. The Level Up content is actually a good case in point of that. For some reason, enlarging the canvas by 100-200 pixels causes it to zoom the content considerably. I'll see if there's a way to address that. Setting width instead of height could be an option, but I also want to make sure we don't end up shrinking the content too much. I think ultimately what we want is to have the ability to specify a desired canvas size for the HTML5 app, and maybe have some auto-detection logic in ricecooker and Studio that can offer suggestions based on the content, but I believe that would require us to finish up the "extra_fields" support on ContentNodes? |
Maybe we could define a 'size' setting on the content node, which can be set by a sushi chef or, longer-term, in the studio UI? For example, it could be set to one of:
In all cases, it would expand to 100% of the available width |
To add my two cents - I think @kollivier and @indirectlylit are both right here. We should add a |
closing as superseded by #6873 |
Summary
For some HTML5 content, there is enough height to render the content but the hardcoded size causes the content to be cut off and thus necessitates vertical scrollbars in the HTML5 content itself. This PR makes it so that the content can expand up to 70% of the page's virtual height, while retaining the old hardcoded height as the min-height to minimize issues with existing content.
Reviewer guidance
ProFuturo content in the Science section is a good test of what this fixes, but testing with a variety of HTML5 content is ideal. We may want this to have another more extensive HTML5 QA pass before merging into develop.
References
…
Contributor Checklist
PR process:
Testing:
Reviewer Checklist
yarn
andpip
)