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

dom-flip

v0.4.3

Published

Smooth position animation for web components

Downloads

65

Readme

<dom-flip>

Build Status Greenkeeper badge Published on webcomponents.org

🔀 Smooth position animation for web components.

Demo

This element is an implementation of the FLIP-technique for arbitrary elements. Simply place it around the elements you indend to reorder and they will smoothly slide over the screen when moved.

Installation

This element lives on npm. Install with yarn add dom-flip or npm install --save dom-flip.

Usage

You can use this element together with any element that modifies the DOM. The animated elements must be direct children of the dom-flip element.

To be able to correlate changes in the model to changes to the DOM, this element requires that you give every element a unique ID. This must be an attribute on the element itself and cannot be a property (because properties cannot be observed via MutationObserver).

Polymer's dom-repeat:

<dom-flip>
    <!--
        If you change the order of the elements inside items, the elements will
        smoothly glide to their new place.
    -->
    <dom-repeat items="[[items]]">
        <template>
            <my-item data-flip-id$="[[item.id]]">[[item.name]]</my-item>
        </template
    </dom-repeat>
</dom-flip>

lit-html:

const template = (items: { id: string, name: string }[]) => html`
    <dom-flip>
        ${items.map(item => html`<div data-flip-id="${item.id}">${item.name}</div>`)}
    </dom-flip>
`;

// Render some items
const result = template([
    { id: "1", name: "Hello" },
    { id: "2", name: ", " },
    { id: "3", name: "World!" }
]);
render(result, renderNode);

// ... next animation frame

// Change their order
const result = template([
    { id: "1", name: "Hello" },
    { id: "3", name: "World!" },
    { id: "2", name: ", " }
]);

// Positions are animated and the items will smoothly glide to their new place
render(result, renderNode);

iron-list

Although we wish it did, this element will not work with <iron-list> due to the virtualization. Maybe this can be fixed in the future.

Automatic registration

You can import the custom element class from dom-flip/element if you don't want it to automatically be registered within the custom elements registry.

Performance

The element is designed to avoid layout thrashing as much as possible by batching work into microtasks and to animation frame timing.

License

MIT