Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/schibsted-tech-polska/gardr-plugin-ext-send-size
https://github.com/schibsted-tech-polska/gardr-plugin-ext-send-size
Last synced: 3 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/schibsted-tech-polska/gardr-plugin-ext-send-size
- Owner: Schibsted-Tech-Polska
- Created: 2014-11-07T09:07:29.000Z (about 10 years ago)
- Default Branch: master
- Last Pushed: 2014-11-12T15:31:38.000Z (about 10 years ago)
- Last Synced: 2024-10-08T14:23:25.661Z (about 1 month ago)
- Language: JavaScript
- Size: 121 KB
- Stars: 0
- Watchers: 12
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Gardr Send Size Plugin (Ext)
Gardr plugin for sending size of an iframe content to host at any given time.
## Install
```
npm install gardr-plugin-ext-send-size --save
```## Bundle
In your ext bundle file:
```javascript
var gardrExt = require('gardr-ext');
var sendSize = require('gardr-plugin-ext-send-size');gardrExt.plugin(sendSize);
module.exports = gardrExt;
```## Usage
This plugin uses [cross-domain-events](https://github.com/finn-no/cross-domain-events) to communicate between frames with "plugin:send-size" namespace.
To trigger it in host:
```javascript
var xde = require('cross-domain-events');xde.on('plugin:send-size', function(response) { // listen for plugin:send-size response
console.log(response.data.id); // id of an gardr iframe
console.log(response.data.size); // object containing width and height of iframe contents
});xde.sendTo(document.querySelector('#banner').contentWindow, 'plugin:send-size'); // send plugin:send-size trigger to iframe inside div#banner
```