Coder Social home page Coder Social logo

Comments (8)

henrygd avatar henrygd commented on August 16, 2024

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.

redtopia avatar redtopia commented on August 16, 2024

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.

henrygd avatar henrygd commented on August 16, 2024

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.

redtopia avatar redtopia commented on August 16, 2024

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.

redtopia avatar redtopia commented on August 16, 2024

@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.

henrygd avatar henrygd commented on August 16, 2024

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.

redtopia avatar redtopia commented on August 16, 2024

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.

henrygd avatar henrygd commented on August 16, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.