Skip to content

πŸ–± An animated custom cursor effects for interactive elements like navigation - w/ VueJS - SSR Compatible

License

Notifications You must be signed in to change notification settings

urbgimtam/vue-cursor-fx

Β 
Β 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸŽ‰ Vue Cursor Fx

An animated custom cursor effects for interactive elements like navigation - w/ VueJS - SSR Compatible

npm version npm downloads License

Installation

This package is available on npm.

    # Deps
    npm install --save @luxdamore/vue-cursor-fx

Usage

As a component

    // Global component and css
    import { CursorFx } from '@luxdamore/vue-cursor-fx';
    import '@luxdamore/vue-cursor-fx/dist/CursorFx.css';

    // Install
    Vue.component(
        CursorFx.name,
        CursorFx
    );


    // Or
    // in a .vue file
    import { CursorFx } from '@luxdamore/vue-cursor-fx';

    export default {
        components: {
            'cursor-fx': CursorFx,
        },
    };

    <style src="@luxdamore/vue-cursor-fx/dist/CursorFx.css"></style>

As a global plugin

    // Plugin
    import CursorFx from '@luxdamore/vue-cursor-fx';
    import '@luxdamore/vue-cursor-fx/dist/CursorFx.css';

    // Install
    Vue.use(
        CursorFx
    );

Browser's way

    <!doctype html>
    <html>
        <head>

            <!-- CursorFx style -->

                <!-- Old way -->
                <link rel="stylesheet" href="https://unpkg.com/@luxdamore/vue-cursor-fx@latest/dist/CursorFx.css" />
                <!-- end old way -->

                <!-- New way -->
                <link rel="preload" href="https://unpkg.com/@luxdamore/vue-cursor-fx@latest/dist/CursorFx.css" as="style" onload="this.rel='stylesheet'" />
                <link rel="preload" href="https://unpkg.com/@luxdamore/vue-cursor-fx@latest/dist/CursorFx.umd.min.js" as="script" />
                <!-- end new way -->

            <!-- end CursorFx style -->

        </head>
        <body>

            <!--
                Others script (ex. VueJs) and html.
            -->

            <!-- CursorFx script -->
                <script src="https://unpkg.com/@luxdamore/vue-cursor-fx@latest/dist/CursorFx.umd.min.js"></script>
            <!-- end CursorFx script -->

        </body>
    </html>

Markup

Use one time in the main file of your project or in every views, where you want it.

    <button
        type="button"
        title="Special button"
        data-cursor-hover
    >
        Add `data-cursor-hover` to an every html elements that you want to see the cursor bigger on hover
    </button>

    <button
        type="button"
        title="Special button"
        data-cursor-hidden
    >
        Add `data-cursor-hidden` to an every html elements that you want to hide the cursor on hover
    </button>

    <button
        type="button"
        title="Special button"
        data-cursor-hover
        data-cursor-mix-blend-mode="difference"
    >
        Add `data-cursor-mix-blend-mode` to an every html elements that you want to change the mix-blend-mode type.
    </button>

    <cursor-fx />

Options

N.B.: the cursor is not activated on touchscreen devices.

Slots

    # Available
    slot="default"  # Add some content in the middle of the cursor

Events

    <cursor-fx
        @before-start="onBeforeStart"
        @after-start="onAfterStart"
        @ready="onReady"
        @before-destroy="onBeforeDestroy"
        @after-destroy="onAfterDestroy"
    ></cursor-fx>

Props

Attribute Type Default Required About
config Object {} false The default options applied to cursor, see below the BASE_CONFIG
color String #333333 false Color for the cursor
color-hover String #333333 false Color, on hover, for the cursor
outside-size String null false The size of outer circle
inside-size String null false The size of inner dot
shape String null false Only available shapes are circle and square
delay String, Number 60 false Activate cursor after x seconds
mix-blend-mode String null false Set the global mix-blend-mode style
force-custom-slot Boolean false false Show or hide the internal default slot
allow-on-mobile Boolean false false Allow the cursor on mobile devices
hide-outside Boolean false false Hide outer circle
hide-inside Boolean false false Hide inner dot
disabled Boolean false false Disable the activation of the cursor
    const BASE_CONFIG = {
        lerps: {
            dot: 1,
            circle: 0.18,
            custom: 0.23,
        },
        scale: {
            ratio: 0.18,
            min: 0.5,
            max: 1,
        },
        opacity: 0.1,
    };

Methods

    <!-- App.vue -->
    <template>
        <div>

            <cursor-fx ref="cursor" disabled />

        </div>
    </template>

    <!-- Component -->
    <script>
        export default {
            mounted() {

                this.$refs.cursor.start();

                // Other methods
                // this.$refs.cursor.destroy();
                // this.$refs.cursor.refresh();

            },
        },
    </script>

Integrations

VueRouter
    <!-- App.vue -->
    <template>
        <div>

            <router-view></router-view>

            <cursor-fx />

        </div>
    </template>
NuxtJs
  • For the entire website: place the component in the desired layouts (ex. layouts/default.vue);
  • For some pages only: place the component in the desired pages (ex. pages/index.vue).
    <!-- layout/default.vue -->
    <template>
        <div>

            <nuxt />

            <cursor-fx />

        </div>
    </template>

🐞 Issues

Please make sure to read the Issue Reporting Checklist before opening an issue. Issues not conforming to the guidelines may be closed immediately.

πŸ‘₯ Contribution

Please make sure to read the Contributing Guide before making a pull request.

πŸ“– Changelog

Details changes for each release are documented in the release notes.

πŸ“ƒ License

MIT License // Copyright (Β©) 2020-present Luca Iaconelli

πŸ’Έ Are you feeling generous today? :)

Do you want to share a beer? We can be good friends.. Paypal // Patreon

It's always a good day to be magnanimous - cit

πŸ’Ό Hire me

Otechie

ko-fi

πŸ’˜ Inspired by

CustomCursors by Tympanus


πŸ’‘ Lighthouse

Lighthouse audit score

About

πŸ–± An animated custom cursor effects for interactive elements like navigation - w/ VueJS - SSR Compatible

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Vue 45.3%
  • JavaScript 43.8%
  • SCSS 5.3%
  • HTML 5.1%
  • Shell 0.5%