Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

rubber-band

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

rubber-band

Unapologetically evergreen-only supporting iframe resizer

  • 0.1.3
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
2
increased by100%
Maintainers
1
Weekly downloads
 
Created
Source

rubberband

Unapologetically evergreen-only supporting iframe resizer

Usage

1. Browserify
  • Install via npm npm install --save rubber-band

  • In your host document

// content.js
import {content} from 'rubber-band';
content();
  • In your embedded document
// host.js
import {host} from 'rubber-band';

let els = document.querySelectorAll('.js-rubberband');
let frames = Array.prototype.slice.call(els).map(host);
2. Plain old javascript files
  • In your host document
<body>
	<!-- host.html -->
	<iframe src="./content.html" class="js-rubberband">
	<script src="rubberband/distribution/rubber-band.host.min.js" async="async"></script>
</body>
  • In your embedded document
<body>
	<!-- content.html -->
	<script src="rubberband/distribution/rubber-band.content.min.js" async="async"></script>
</body>

API

  • rubberband.host(frame /* frame element */, options /* options object */);
	{
		"name": "rubberband", // Name used for signaling between frames
		"domain": "*",        // Domain parameter passed to window.postMessage
		"throttle": 300       // Throttle interval used to send messages in milliseconds
		"callback": function defaultCallback(frame, height) {
			// Called whenever receiving a message from iframe
			// Called with params
			// * height (integer): Height to apply to iframe
			// * frame (HTMLElement): iframe to apply the height to
			frame.style.height = `${height}px`;
		}
	}
	{
		start(),              // Start frame resizing
		stop(),               // Stop frame resizing
		request()             // Send a request for content height measurement to the containing iframe
	}
  • rubberband.content(options /* options object */);
	{
		"name": "rubberband", // Name used for signaling between frames
		"domain": "*",        // Domain parameter passed to window.postMessage
		"throttle": 300       // Throttle interval used to send messages in milliseconds
	}
	{
		start(),              // Start frame resizing
		stop(),               // Stop frame resizing
	}

Keywords

FAQs

Package last updated on 24 Aug 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc