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

vue-inner-focus

v0.1.0

Published

A vue directive to detect focusin/out in a component

Downloads

9

Readme

vue-in-out

A vue directive factory and directives to simplify in/out state changes such as mousein/mouseout, focusin/focusout, etc.

Installation

npm install vue-in-out

Browser/polyfill requirements

  • classList API
  • Object destructuring
  • Arrow functions
  • Template strings

Note: In short, you may want to transpile es6 and polyfill the classList API if you are supporting older browsers, or Safari.

Directives

Some simple directives to simplify user interaction state management. These are essentially a shorthand for adding multiple bindings that are commonly used together.

vue-inner-focus

Tracks focusin/focusout. On focusin adds the focused class to the element with the directive. On focusout, removes it. Can take a callback event which is called with either true (focusin), or false (focusout).

import innerFocus from 'vue-in-out/src/inner-focus';

export myComponent = {
    directives: {
        'inner-focus': innerFocus,
    },
    template: `
        <div class="testDiv" v-inner-focus>
            <button class="testButton"></button>
        </div>`
};

Focusout Timeout

To accomodate some browser quirks and to ensure that the outEvent timeout has a chance to be cleared by inEvents there is a 50ms delay before the outEvennt fires. If this does not suit your needs, please see the directive factory below.

Customization

This simply allows a focused class to be added or removed. Custom classes and callbacks are supported:

import innerFocus from 'vue-in-out/src/inner-focus';

export myComponent = {
    directives: {
        'inner-focus': innerFocus,
    },
    template: `
        <div class="testDiv" v-inner-focus:customClass="onFocusChange">
            <button class="testButton"></button>
        </div>`,
    methods: {
        onFocusChange(isFocused) {
            console.log('This is focused', isFocused);
        }
    },
};

vue-hovered

import innerFocus from 'vue-in-out/hovered';

Default class is hovered. Otherwise, behaves identically to the inner-focus directive.

Directive Factory

This allows easy creation of directives similar to those above. For example, the inner-focus directive is simply:

import { inOutDirectiveFactory } from 'vue-in-out/src/in-out-factory';

export const DEFAULT_CLASS = 'focused';

export default inOutDirectiveFactory({
    inEvent: 'focusin',
    outEvent: 'focusout',
    activeClass: DEFAULT_CLASS,
});

Options

| Key | Default | Description | |-----|---------|-------------| | inEvent | None | The event such as focusin to start with | | outEvent | None | The event such as focusout to end with | | activeClass | None | The class to attach when in the in state | | defaultCallback | () => {} | A callback that will be called with true when moving to the in state and false when moving to the out state. This will typically be overridden in the view with callback bound to the Vue instance (eg onFocusChange above). | | outTimeout | 50 | The time to wait between receiving the out event and actually triggering the callback and removing the active class. |