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

modularload

Package Overview
Dependencies
Maintainers
1
Versions
30
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

modularload

Dead simple page transitions and lazy loading.

  • 1.0.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
19
increased by11.76%
Maintainers
1
Weekly downloads
 
Created
Source

modularLoad

Dead simple page transitions and lazy loading.

Installation

npm install modularload

Why

  • Simple
  • Lightweight
  • Minimal configuration
  • No dependencies

Usage

import modularLoad from 'modularload';

this.load = new modularLoad({
    enterDelay: 300
});
<div data-load-container>
    <h1>Hello</h1>
    <a href="/blog">Read more</a>
</div>
With transitions
import modularLoad from 'modularload';

this.load = new modularLoad({
    enterDelay: 300,
    transitions: {
        transitionName: {
            enterDelay: 450
        },
        transitionTwoName: {
            enterDelay: 600
        }
    }
});
<html data-page="home">
   <body> 
        <nav>
            <a href="/contact" data-load="transitionName">Contact</a>
        </nav>
        <div data-load-container>
            <h1>Hello</h1>
            <a href="/blog" data-load="transitionTwoName">Read more</a>
        </div>
   </body>
</html> 
With lazy images
import modularLoad from 'modularload';

this.load = new modularLoad();
<div data-load-container>
    <header data-load-style="background-image: url('images/header.jpg');">
        <h1>Hello</h1>
    </header>
    <main>
        <img data-load-src="images/img.jpg">
        <a href="/blog">Read more</a>
    </main>
</div> 
With events
import modularLoad from 'modularload';

this.load = new modularLoad();

this.load.on('loaded', (transition, oldContainer, newContainer) => {
    console.log('👌');

    if (transition == 'transitionName') {
        console.log('🤙');
    }
});

Options

OptionTypeDefaultDescription
namestring'load'Data attributes name
loadingClassstring'is-loading'Class when a link is clicked
loadedClassstring'is-loaded'Class when the new container enters
readyClassstring'is-ready'Class when the old container exits
transitionsPrefixstring'is-'Custom transitions class prefix
enterDelaynumber0Minimum delay before the new container enters
exitDelaynumber0Delay before the old container exists after the new enters
transitionsobject{}Custom transitions options

Attributes

AttributeValuesDescription
data-load-containerContainer you want to load
data-loadstring, falseTransition name or disable transition
data-load-srcstringLazy load src attribute
data-load-srcsetstringLazy load srcset attribute
data-load-stylestringLazy load style attribute
data-load-hrefstringLazy load href attribute

Events

EventArgumentsDescription
loadingtransition, oldContainerOn link click
loadedtransition, oldContainer, newContainerOn new container enter
readytransition, newContainerOn old container exit
imagesOn all images load

FAQs

Package last updated on 26 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

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