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

@digitalnatives/vue-super-cursor

v1.0.3

Published

A flexible library for adding custom (super) cursors to your vue/nuxt apps.

Downloads

5

Readme

Vue Super Cursor - Vue 2

A flexible library for adding custom (super) cursors to your vue/nuxt 2 apps. Flexible configuration, good browser support and some built in solutions to common problems.

Installation

yarn add @digitalnatives/vue-super-cursor

Usage examples

<template>
    <div>
        <!-- default -->
        <SuperCursor />
        
        <!-- use custom element as cursor -->
        <SuperCursor>
            <svg>....</svg>
        </SuperCursor>

        <!-- Nuxt usage, prevents error on initial page load  -->
        <client-only>
            <SuperCursor />
        </client-only>
       
    </div>
</template>

<script>
import SuperCursor from '@digitalnatives/vue-super-cursor'

export default {
    components: {
      SuperCursor
    }
}
</script>

Props

The component is configurable through props.

| Prop | Type | Required | Description | Object variables | Default value | |---------------------------|--------|------------|----------------------------------------------------------------------------------------------------------------------------------------|-------------------------|---------------------------------------------------------------------------------------------------------------| | throttleDelay | Number | optional | Throttle how often the mutationObserver will fire. | - | 500 | | hoverableElements | Array | optional | Array contains object with a class and elements | class, elements | { class: 'super-cursor--hovering', elements: 'a, button' } | | trailingCursors | Array | optional | Array contains object with a class and gsap_options. For Gsap options see the docs | class, gsap_options | [] |
| mutationObserverOptions | Object | optional | Options see docs MutationObserver | - | { childList: true, subtree: true, attributes: true, characterData: false, attributeFilter: ['open'] } |

Hoverable elements

The hoverable-elements prop lets you to add objects with a selector (elements) and a class. This allows you to define elements that will trigger an even when the cursor hovers over them. It also let's you set a class that will be added to the <body> when this happens. By default the cursor will trigger the class .super-cursor--hovering on the <body> when you hover over <button> and <a> elements.

Example hoverable elements

Let's assume you have a card that should have a different cursor. You could add the hoverable like so:

<SuperCursor :hoverable-elements="[
    {
        class: 'super-cursor--hovering', // keep the default in tact
        elements: 'a, button'
    },
    {
        class: 'super-cursor--hover-card',
        elements: '.card' // select your card with a class selector
    }
]" />

The class .super-cursor--hover-card will now be added to the body when you hover over one of the cards.

You can then style the cursor however you like

body.super-cursor--hover-card .super-cursor {
    background: magenta;
}

The cursor should now turn purple when you hover over a card.

Do not hover

The elements property uses the queryselector api. Any valid css selector should work. You can leverage this to change disable hover behaviour as well. For example like so: elements: 'a:not(.dont-hover-me)'. This should select all <a> elements except the ones with a .dont-hover-me class.

Trailing cursors

The trailing cursors prop allows you to add additional trailing cursors with their own timing function. You can add as many as you like. Each cursor should have a class and a gsap_options property. The gsap_options can be any options available in the gsap.to() api https://greensock.com/docs/v3/GSAP/gsap.to()

Add one like so:

<SuperCursor :trailing-cursors="[
    {
        class: 'super-cursor--trailing', // the class the cursor will have
        gsap_options: { // Greensock options
            duration: 0.1
        }
    },    
]" />

Base styles

This component contains some boilerplate CSS to provide an accessible base to work from. It is quite simple and should be easy to customize.

body {
  * {
    cursor: none; // Hide the default cursor
  }

  .super-cursor {
    opacity: 0;
  }

  .super-cursor-trail {
    opacity: 0;
  }

  @media ( hover: hover ) {
    &:hover .super-cursor { // show the cursor when the cursor is inside the <body> element. Fade it out when it leaves the window
      opacity: 1;
    }

    &:hover .super-cursor-trail { // do the same for the cursor trail
      opacity: 1;
    }
  }
}

.super-cursor {
  position: fixed;
  opacity: 0;
  pointer-events: none;
  height: 25px;
  width: 25px;
  background-color: #000;
  z-index: 2147483647;
  transform: translate(-50%, -50%);
  border-radius: 50%;
}

.super-cursor-trail {
  opacity: 0;
}

Questions & contributing

Feel welcome to open issues if you have questions are if you run into bugs.

Or even better submit a pull request :)

Made by Digital Natives Amsterdam