Coder Social home page Coder Social logo

isaaclyman / nyan-cat-festival Goto Github PK

View Code? Open in Web Editor NEW
0.0 2.0 1.0 1.09 MB

~=[,,_,,]:3 Turn your website into a custom nyan cat festival.

Home Page: http://isaaclyman.com/nyan-cat-festival/docs

License: MIT License

TypeScript 100.00%
nyan-cat nyan npm-package

nyan-cat-festival's Introduction

nyan-cat-festival

Turn your website into a custom nyan cat festival.

Demo: http://isaaclyman.com/nyan-cat-festival/docs

~=[,,_,,]:3

ฦ:[,,_,,]=~

~=[,,_,,]:3

Installation

npm install --save nyan-cat-festival

API

First, import the library:

import Nyan from 'nyan-cat-festival'

Then set the options for your festival:

// Simple festival for simple cats
const festival = new Nyan({
  cues: [{
    start: 'left',
    end: 'right'
  }]
})

// Advanced festival for hacker cats
const festival = new Nyan({
  song: 'http://www.hochmuth.com/mp3/Haydn_Cello_Concerto_D-1.mp3',
  transitionDuration: 5 * 1000,
  transitionTiming: 'cubic-bezier(0.0, 0.0, 0.85, 1.0)',
  zIndex: 100,
  cues: [{
    delay: 0,
    start: 'left',
    zIndex: 5
  }, {
    delay: 1500,
    start: 'left-top',
    zIndex: 5
  }, {
    delay: 3000,
    start: 'left-bottom',
    end: 'right-top',
    transitionDuration: 10 * 1000,
    transitionTiming: 'ease-in',
    zIndex: 10
  }]
})

And finally, get your nyan on:

festival.nyan()

Options

song: (optional) The URL of the song to play in the background, or an HTMLAudioElement object that is ready to play. If this is null, no song will be played. By default, this is the theme song for the show Mock Trial with J. Reinhold.

transitionDuration: (optional) The default duration in milliseconds of each cat's transition from its start position to its end position. By default, this is 5000.

transitionTiming: (optional) The default timing function to use for the transition of the cats from their start position to their end position. By default, this is a cubic bezier function that makes the cats fly in very quickly, then fly at a slower speed across the screen.

zIndex: (optional) The z-index of the stacking context where all the cats will be appended. The stacking context is a <div> attached to your <body> element. By default, this is 100.

Cues

The cues option is an array of objects, each of which represents a single nyan cat. The options for a cue are:

delay: (optional) The number of milliseconds after the nyan() function is called before the cat should appear. The default is 0.

start: (optional) The position where the cat should begin (off-screen). The 12 possible values, starting at the bottom of the left side and going clockwise, are 'left-bottom', 'left', 'left-top', 'top-left', 'top', 'top-right', 'right-top', 'right', 'right-bottom', 'bottom-right', 'bottom', 'bottom-left'. By default, this is 'left'.

end: (optional) The position where the cat should end (off-screen). This accepts the same values as the start option. By default, this is 'right'.

transitionDuration: (optional) An override duration to use for this cat's transition.

transitionTiming: (optional) An override timing function to use for this specific cat.

zIndex: (optional) The z-index of this specific cat. Keep in mind that z-index can only be used to position cats relative to each other, not to your app, since they exist in a different stacking context. By default, this is 1.

Troubleshooting

If you try to nyan right when the page loads, the audio won't work on modern browsers due to autoplay policies. You'll have to nyan in response to a user event (like a click).

License

MIT Licensed.

nyan-cat-festival's People

Contributors

isaaclyman avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.