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

ndla-article-scripts

Package Overview
Dependencies
Maintainers
1
Versions
43
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ndla-article-scripts

A collection of functions for making article content responsive (and interactive)

  • 0.0.3
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
17
increased by325%
Maintainers
1
Weekly downloads
 
Created
Source

ndla-article-scripts

A collection of functions for making article content responsive (and interactive)

Installation

$ npm install ndla-article-scripts

Usage

Plain javascript (embed scripts)

import {
  addEventListenerForResize,
  updateIFrameDimensions,
  addAsideClickListener,
} from 'ndla-article-scripts';

window.onload = () => { // Invoke after article content has loaded
  updateIFrameDimensions();
  addEventListenerForResize();
  addAsideClickListener();
};

React

import {
  addEventListenerForResize,
  updateIFrameDimensions,
  addAsideClickListener,
  removeEventListenerForResize,
  removeAsideClickListener,
} from 'ndla-article-scripts';

class Article extends Component {

  componentDidMount() {
    addEventListenerForResize();
    updateIFrameDimensions();
    addAsideClickListener();
  }

  componentWillUnmount() {
    removeEventListenerForResize();
    removeAsideClickListener();
  }

  render() {
    const { article } = this.props;
    return (
      <article>
        <h1>{article.title}</h1>
        <div dangerouslySetInnerHTML={{ __html: article.content }} />
      </article>
    );
  }
}
export default Article;

API(functions)

articleScripts.updateIFrameDimensions()

Update iframe height and width to fit screen/window size.

articleScripts.addEventListenerForResize()

Adds an resize event listener on window. The listener calls updateIFrameDimensions on browser window resize.

articleScripts.removeEventListenerForResize()

Removes the event listener added by addEventListenerForResize.

articleScripts.addAsideClickListener()

Adds an click listener on aside buttons for expanding the content on small screens.

articleScripts.removeAsideClickListener()

Removes click listeners added by removeAsideClickListener.

Keywords

FAQs

Package last updated on 24 Apr 2017

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