Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

vue-easter-egg-trigger

Package Overview
Dependencies
Maintainers
1
Versions
30
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

vue-easter-egg-trigger

This packages makes it nice and easy to add Easter Egg triggers to your Vue site.

  • 0.1.23
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
3
Maintainers
1
Weekly downloads
 
Created
Source

Vue Easter Egg Trigger

GitHub package.json version NPM_PACKAGE GitHub license

This packages makes it nice and easy to add Easter Egg triggers to your Vue site.

Installation

npm i vue-easter-egg-trigger

Usage

import Vue from 'vue';
import EasterEggTrigger from 'vue-easter-egg-trigger';

Vue.use(EasterEggTrigger);

Plugin Options

NameTypeDefaultDescription
delayInteger500Determins the timeout before the event lister resets
keysArray['ArrowUp', 'ArrowUp', 'ArrowDown', 'ArrowDown', 'ArrowLeft', 'ArrowRight', 'ArrowLeft', 'ArrowRight', 'b', 'a']The keys a user needs to enter to trigger the easter egg. The default combination is the konami code.
patternArray[38, 38, 40, 40, 37, 39, 37, 39, 66, 65]The keyCode a user enters to trigger the easter egg. This is a fallback for the keys option as it is depreciated.
typeStringkeydownThe type of action the trigger will be listening for
Overriding the plugin default options
import Vue from 'vue';
import EasterEggTrigger from 'vue-easter-egg-trigger';

Vue.use(EasterEggTrigger, {
  delay: 1000,
  keys: ['ArrowUp', 'ArrowDown'],
  pattern: [38, 40],
  type: 'keyup'
});

Easter Egg Options

NameTypeDefaultDescription
callbackFunctionnullThe callback function
destroyBusBooleanfalseDetermines if a bus $on event is destroyed automatically
keysArrayfalseThe key/click combination a user does to trigger easter egg.
nameStringeaster-eggIdentifier & used for even bus callback
patternArrayfalseThe key combination a user does to trigger easter egg. (fallback for keys)
targetStringdivUse this to target DOM elements, Id's, or Class Names. Used with click events.
withBusBooleantrueDetermines if a bus event is emitted

Instance Methods

There are two instance methods available to use. $easterEgg $easterEggTrigger

Key Event Examples

The default key combination to trigger the easter egg is the Konami Code.

ex. ↑ ↑ ↓ ↓ ← → ← → b a

Bare Egg Example.
this.$bus.$on('easter-egg', () => {
  // do something...
});

this.$easterEgg();
Key Event with Callback & Bus Emit
this.$bus.$on('easter-egg', () => {
  // also do something...
});

this.$easterEgg({
  name: 'easter-egg',
  callback() {
    // do something ...
  },
});
Key Event with Callback only
this.$easterEgg({
  name: 'easter-egg',
  callback() {
    // do something ...
  },
  withBus: false,
});

Mouse Event Examples

First you will need to set the type in the plugin options.

Available types of Mouse Events: click, dblclick, mouseup, mousedown. When using dblclick the pattern will only work with one double click. Ex. pattern: ['dblclick']

import Vue from 'vue';
import EasterEggTrigger from 'vue-easter-egg-trigger';

Vue.use(EasterEggTrigger, {
  type: 'click'
});
Mouse Event with Callback & Bus Emit
this.$bus.$on('easter-egg', () => {
  // also do something...
});

this.$easterEgg({
  name: 'easter-egg',
  pattern: ['click', 'click'],
  callback() {
    // do something...
  },
});
Mouse Event using a DOM element target
this.$easterEgg({
  name: 'easter-egg',
  pattern: ['click', 'click'],
  target: 'h1',
});
Mouse Event using an ID target
this.$easterEgg({
  name: 'easter-egg',
  pattern: ['click', 'click'],
  target: '#foo',
});
Mouse Event using an Class target
this.$easterEgg({
  name: 'easter-egg',
  pattern: ['click', 'click'],
  target: '.foo',
});

More Examples

You can find more examples in the EasterEgg.vue file.

Change Log

CHANGELOG

License

Copyright (c) 2021 WebDevNerdStuff Licensed under the MIT license.

@WebDevNerdStuff

Keywords

FAQs

Package last updated on 28 Apr 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc