Comments (8)
Unfortunately I don't think you can access document properties like that on cross-origin frames, which is what most people will be using.
I can make the BigPicture function return the iframe and a function to update the dimensions, though, to make what you're doing a bit easier. For example that would make it possible to do something like this:
let bpInstance = BigPicture({
el: $(elem).get(0),
iframeSrc: 'iframe.html'
})
let frame = bpInstance.display.querySelector('iframe')
function resizeFrame() {
// add resize logic here to calculate w, h
bpInstance.opts.dimensions = [w, h]
bpInstance.updateDimensions()
}
frame.addEventListener('load', resizeFrame)
window.addEventListener('resize', () => setTimeout(resizeFrame, 1))
You might want to also use the onClose callback and removeEventListener to clean up the listeners afterward but should work in theory.
from bigpicture.
Thanks... yea there are a few approaches that one could take. I took the liberty to modify the BP source and I got it working nicely by adding a few options. My iframes are local, so I'm not dealing with cross origin issues. I would be happy to share my changes with you, or do a PR... whatever works for you. I did some limited testing and I think my changes don't affect existing functionality, but another set of eyes on it would be great.
from bigpicture.
I'll take a look if you make a fork, but just fyi the main thing I want to avoid is adding weight to the lib.
I definitely agree this should be easier to do, but I don't necessarily want to add code to solve unusual use cases individually. The changes I suggested above give people more to work with in general for custom implementations while only adding 20-30 bytes. It's a compromise, and I know I'm being a stickler, but I want to keep this thing as light as possible. It would make sense in a more feature rich alternative, which I've wanted to do for years but keeps getting put on the back burner. Maybe soon.
from bigpicture.
Cool... I'll fork it. Maybe it will give you some ideas at least. When I was digging in, I could tell that you are being super lightweight-minded and I tried to honor that. If anything, maybe my changes will give you some ideas and you'll have a better way of implementing them.
In a nutshell, I gave the caller much more control over sizing the iframe. But I definitely did not look at the number of bytes that I added to the library! :)
from bigpicture.
@henrygd I have my changes ready to push up... not sure if you would be okay putting in a PR, or if you just want me to send you the modified file... let me know and I'm ready to get it to you.
from bigpicture.
You can do a pr, or just fork the repo and link after the changes are pushed. I'm flying out to my brother's wedding tomorrow so I probably won't get around to looking at it until at least after the weekend.
from bigpicture.
FYI, I created a PR with my changes in the dist
directory because the src
directory did not have an identical BigPicture.js file in it. So I modified the one that's in production.
from bigpicture.
Thanks for the PR, sorry it took so long to get back around to this. I think it's just a bit too much to add given the scope of the library and the unlikeliness of others needing the same functionality, but I did expose the updateDimensions
function to make this easier in the future.
https://github.com/henrygd/bigpicture#change-dimensions-of-embed--youtube--vimeo
from bigpicture.
Related Issues (20)
- dimensions not working for <video> HOT 3
- Feature request. support for responsive images by using srcset attribute HOT 1
- Destroy BigPicture HOT 2
- Add support for start time for YouTube videos HOT 1
- Feature request. Make use of youtube nocookie domain. HOT 2
- Content Security Error - refused to evaluate string HOT 2
- Es6 modules HOT 1
- Separate scripts for video demos HOT 3
- Feature request: Option to pass controlslist value to HTML Video HOT 2
- Feature request: add swipe support HOT 3
- Feature request: support pinch zoom in/out HOT 1
- Full screen button on Vimeo player not working when browser is full screen HOT 1
- Feature request: Publish 2.6.0 to npm HOT 1
- Feature request : control the video looping HOT 6
- Feature Request: Fill screen HOT 3
- Youtube videos start in lower quality HOT 9
- HLS Support? HOT 1
- If ytNoCookie is true, YouTube video will not autoplay in Safari HOT 2
- Implement on plain-Jane, non-framework, basic HTML/JS/CSS pages HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from bigpicture.