npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@open-iframe-resizer/core

v1.3.0

Published

Open-source modern iframe resizer

Downloads

5,791

Readme

Open Iframe Resizer

NPM Version NPM License

Overview

A modern, lightweight alternative for resizing iframes dynamically. It is shipped under the MIT license, making it usable in commercial projects.

If you found this project helpful, please consider starring the repository!

Getting Started

Browser (ES6 modules)


<script type="module">
  import { initialize } from "https://cdn.jsdelivr.net/npm/@open-iframe-resizer/core@latest/dist/index.min.js";

  initialize({}, "#my-iframe");
</script>

You can found a working example here

Package

Note you can also install the core package through npm:

npm install @open-iframe-resizer/core

React

A React component is also available:

npm install @open-iframe-resizer/react

Notes

Performing actions after a resize

You can execute a custom function after an iframe has been resized. Also, you can use built-in functions like updateParentScrollOnResize to help keep the iframe within the viewport after resizing:

import { initialize, updateParentScrollOnResize } from "https://cdn.jsdelivr.net/npm/@open-iframe-resizer/core@latest/dist/index.min.js";

initialize({ onIframeResize: updateParentScrollOnResize }, "#myIframe");

Resize iframes from a different origin

  • If you have control over the embedded page, you need to load the script on your child page to enable messaging between the two windows (you do not need to call the initialize function in the child; loading the module is sufficient).

    Here is an example of the parent page and the child.

  • If you have no control over the child iframe domain, and, by chance, the child page loads the legacy iframe-resizer script, you can initialize the library with the compatibility mode; it will try to connect to the child iframe:

    initialize({ enableLegacyLibSupport: true }, "#my-iframe");

Comparison with iframe-resizer

This library is very good, but it has changed its license, so it is no longer usable in closed-source projects for free. I decided to replicate some parts of the API, as it may facilitate migration to this project.

Some features from this library are missing, but they could be implemented in future versions.

Browser support

| Chrome | Safari | Firefox | Opera | IE | |--------|--------|---------|-------|-------| | 64+ | 13.1+ | 69+ | 51+ | 🙅‍♂️ |