🚀 DAY 5 OF LAUNCH WEEK: Introducing Socket Firewall Enterprise.Learn more →
Socket
Book a DemoInstallSign in
Socket

@sebgroup/ng-magic-iframe

Package Overview
Dependencies
Maintainers
4
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@sebgroup/ng-magic-iframe

[![Build Status](https://travis-ci.com/sebgroup/ng-magic-iframe.svg?token=tzrdkWGEu776AVobzRhp&branch=master)](https://travis-ci.com/sebgroup/ng-magic-iframe) [![Commitizen friendly](https://img.shields.io/badge/commitizen-friendly-brightgreen.svg)](http:

latest
npmnpm
Version
1.0.2
Version published
Weekly downloads
4
-73.33%
Maintainers
4
Weekly downloads
 
Created
Source

SEB Magic Iframe

Build Status Commitizen friendly semantic-release

Install with npm

npm install @sebgroup/ng-magic-iframe --save

Add to app.modules

import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';

import { AppComponent } from './app.component';
import { NgMagicIframeModule } from '@sebgroup/ng-magic-iframe';

@NgModule({
  declarations: [
    AppComponent
  ],
  imports: [
    BrowserModule,
    NgMagicIframeModule
  ],
  providers: [],
  bootstrap: [AppComponent]
})
export class AppModule { }

Allow synthetic default imports

If you run into the following error: @types/element-resize-detector/index"' has no default export you need to allow synthetic default imports as the type definitions for element-resize-detector, which this library depends on, has no default export declared. In tsconfig.json in your root project folder, set allowSyntheticDefaultImports to true:

{
  "compileOnSave": false,
  "compilerOptions": {
    "allowSyntheticDefaultImports" : true,
    ...
}

Usage

Basic

<seb-ng-magic-iframe [source]="'/assets/first-page.html'"></seb-ng-magic-iframe>

Advanced

<seb-ng-magic-iframe [source]="'/assets/first-page.html'"
                     [styles]="'body { background: white; }'"
                     [styleUrls]="['/assets/css/external-stylesheet.css', '/assets/css/fonts.css']"
                     [autoResize]="false"
                     [resizeDebounceMillis]="0"
                     (iframeEvent)="foo($event)">
                     <!-- PLACEHOLDER FOR LOADING CONTENT -->
</seb-ng-magic-iframe>

Configuration and options

@Inputs

@InputDescriptionDefault
sourcePath to iframe content source.n/a
stylesApply/inject inline styles to the iframe (Optional).n/a
styleUrlsAdd one or more stylesheets to the iframe, note that the iframe won't be visible until they've loaded (Optional).n/a
autoResizeAuto resize the iframe when the inner content changes height (Optional).true
resizeDebounceMillisDebounce time in milliseconds for resize event to prevent race condition (Optional).50

@Outputs

@OutputDescription
iframeEventListen for state changes in iframe, see list of events below.

Iframe events

@InputDescription
iframe-clickEvent emitted when element inside iframe has been clicked.
iframe-keyupEvent emitted when keyup event emitted inside iframe.
iframe-unloadedEvent emitted when iframe triggers unload event (url in iframe changes).
iframe-styles-addedEmitted when styles have been added.
iframe-stylesheet-loadEmitted when external stylesheets start loading.
iframe-stylesheet-loadedEmitted when external stylesheets have finished loading.
iframe-all-stylesheets-loadedEmitted when all external stylesheets have finished loading (only emitted if more than one external stylesheets).
iframe-loadedEmitted when iframe has finished loading (including optional styles and/or stylesheets).
iframe-loaded-with-errorsEmitted when iframe has encountered errors after loading (usually related to CORS and inability to access iframe content).
iframe-resizedEmitted when the iframe changes size.

Custom content loader

SEB Magic iframe uses content projection together with ng-content to show custom content while the iframe is loading. Simply add your own component or markup like this:

<seb-ng-magic-iframe [source]="'/assets/first-page.html'">
  <div class="skeleton-loader"></div> <!-- replace with your own code -->
</seb-ng-magic-iframe>

Run locally

  • Clone the repository
  • Run npm install
  • Run npm start and navigate to http://localhost:4200/. The app will automatically reload if you change any of the source files.

FAQs

Package last updated on 16 Mar 2019

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