npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@redsift/d3-rs-reveal

v0.1.0

Published

Performs an animated transition between images.

Downloads

10

Readme

d3-rs-reveal

Circle CI npm MIT

d3-rs-reveal generate a SVG based transition to reveal an image. Typically large images take time to download and present leaving the user with an unsatisfying experience. This module used animated SVG filters and preview images to blend the transition between the low resolution preview and the full resolution asset when available.

Example

View @redsift/d3-rs-reveal on Codepen

You may use your browser's throttling tools and cache to simulate different load and reload scenarios.

Usage

Browser

<script src="//static.redsift.io/reusable/d3-rs-reveal/latest/d3-rs-reveal.umd-es2015.min.js"></script>
<script>
    var reveal = d3_rs_reveal.html()
                .placeholder(placeholder)
                .imgWidth(imgWidth)
                .imgHeight(imgHeight)
                .img(img);
    
    d3.select('body').call(reveal);
</script>

ES6

import { reveal } from "@redsift/d3-rs-reveal";
let eml = reveal.html();
...

Require

var reveal = require("@redsift/d3-rs-reveal");
var eml = reveal.html();
...

Creating images

The supplied preview filter was build to hide heavy compression artefacts so the preview can be exported with extreme levels of compression. At these levels, it becomes practical to base64 and inline the image data.

$ convert photo-src.jpg -resize 256 -blur 1.1 -quality 10 -profile sRGB_v4_ICC_preference.icc -strip photo-dest_0x.jpg
$ base64 photo-dest_0x.jpg

Note that the color profile is converted to sRGB before being stripped from the image. A full discussion on image processing is beyond the scope of this module. gulp-compressedimages provides a tuned pipeline for generating these images in common sizes.

Checking supported features

Formats such as WEBP can reduce the size of the assets while maintaining quality. Unfortunately testing for browser support for the codec required some work. A helper is exposed on this module checkSupported. It returns a promise that can be supplied to the img parameter and transformed to the URL of the desired asset.

import { reveal, checkSupported } from "@redsift/d3-rs-reveal";
let imageReveal = reveal()
                    .placeholder(placeholder)
                    .imgWidth(imgWidth)
                    .imgHeight(imgHeight)
                    .img(checkSupported.then(s => `./hero${s.retina ? '_2x' : ''}.${s.webp ? 'webp' : 'jpg'}`))

Parameters

Property|Description|Transition|Preview ----|-----------|----------|------- classed|String SVG custom class|N