New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

sparef-js

Package Overview
Dependencies
Maintainers
0
Versions
28
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install
Package was removed
Sorry, it seems this package was removed from the registry

sparef-js

A TypeScript library to turn a multi-page app into a single-page app with smooth transitions

unpublished
latest
Source
npmnpm
Version
1.2.8
Version published
Maintainers
0
Created
Source

sparef-js

This Code is a Beta-Version

sparef-js is simple and small JS library that turns a multi-page app into a single-page app via CSS ::view-transitions and a optional prefetch HTML API built in.

install

npm install sparef-js

use

import sparef, { animate } from 'sparef-js';

/**
 * Any <a> that is an internal link inside the <body> tag
 * creates a view-transition when triggered and loads the new page
 * in a SPA like mode.
*/
sparef('body', {
  /**
   * Prefetch links on a given event 
   * and after a given delay.
  */
  prefetch: {
    active: true, // boolean
    event: 'DOMContentLoaded', // any JS Event
    delay: 1000 // integer (loads prefetch link 1s after pageload),
    isSameOrigin: true, // default is "true", optionaly "false" or undefined/not set (=== true)
  },
  transition: {
    duration: 1000, // integer
    delay: 100, // integer
    timeline: 'sequential', // or 'parallel'
    easing: 'ease', // any CSS easing compatible string
    iteration: 1,  // number or "infinte"
    /**
     * 'in' and 'out' sets CSS keyframes,
     * write CSS keframes as a JS Object.
     * Strings get converted from Camel to Kebab Case 
     * via sparef-js and set as temporary CSS animations
     * in the DOM.
    */
    out: {
      from: { opacity: 1, backgroundColor: 'green' },
      to: { opacity: 0, backgroundColor: 'transparent' }
    },
    in: {
      from: { opacity: 0, backgroundColor: 'transparent' },
      to: { opacity: 1, backgroundColor: 'orange' }
    }
  }
});

/**
 * Whatever the globally set transition would be, 
 * the animate function overwrites this on the given element(s)
 * if there are more than 1 header element in the html, it animates
 * all of them.
 */
animate('header', {
 in: {
  from: {
    tranform: 'translate(-100%)'
  },
  to: {
    tranform: 'translate(0)'
  }
 },
 out: {
  from: {
    tranform: 'translate(0)'
  },
  to: {
    tranform: 'translate(-100%)'
  }
 }
})

License

MIT

Keywords

spa

FAQs

Package last updated on 08 Oct 2024

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