All Projects → 4lejandrito → Creepyface

4lejandrito / Creepyface

Licence: mit
A JavaScript library that makes your face follow the pointer. 🤪🖱️👆

Programming Languages

javascript
184084 projects - #8 most used programming language
typescript
32286 projects

Projects that are alternatives of or similar to Creepyface

React Easy Swipe
Easy handler for common swipe operations
Stars: ✭ 85 (-79.37%)
Mutual labels:  mouse, touch
interfaces
A diverse set of royalty-free user avatars to be used for marketing graphics and application screenshots.
Stars: ✭ 50 (-87.86%)
Mutual labels:  picture, face
React Rotation
React rotation component
Stars: ✭ 102 (-75.24%)
Mutual labels:  mouse, touch
Tdtouchid
TDTouchID是一个封装好的指纹、FaceID验证库,可以用来做iOSAPP的登录/支付等验证。
Stars: ✭ 191 (-53.64%)
Mutual labels:  face, touch
getting-touchy-presentation
Everything you (n)ever wanted to know about touch and pointer events
Stars: ✭ 42 (-89.81%)
Mutual labels:  touch, touch-events
Any Touch
👋 手势库, 按需2kb~5kb, 兼容PC / 移动端
Stars: ✭ 567 (+37.62%)
Mutual labels:  mouse, touch
Kursor
Cursor style with javascript and css
Stars: ✭ 140 (-66.02%)
Mutual labels:  mouse, javascript-library
Zoom
Javascript library to do pinch zoom that preserves scale and rotation correctly.
Stars: ✭ 130 (-68.45%)
Mutual labels:  touch, javascript-library
Cat-Face-Detector-with-OpenCV-and-JavaFX
📹 A Small OpenCV (Open Source Computer Vision) Example, who has the ability to detect multiple cat faces at the same time 🐱
Stars: ✭ 24 (-94.17%)
Mutual labels:  picture, face
visage
Add virtual makeup to picture of a face.
Stars: ✭ 97 (-76.46%)
Mutual labels:  picture, face
Genetic Algorithm Montage
genetic algorithm for self-referential image approximation.
Stars: ✭ 86 (-79.13%)
Mutual labels:  face, picture
Hover On Touch
A pure Javascript Plugin for an alternative hover function that works on mobile and desktop devices. It triggers a hover css class on »Taphold« and goes to a possible link on »Tap«. It works with all html elements.
Stars: ✭ 256 (-37.86%)
Mutual labels:  touch, touch-events
React Native Fingerprint Scanner
Provide Fingerprint, Touch ID, and Face ID Scanner for React Native (Compatible with both Android and iOS)
Stars: ✭ 704 (+70.87%)
Mutual labels:  face, touch
Inputsystem
An efficient and versatile input system for Unity.
Stars: ✭ 1,013 (+145.87%)
Mutual labels:  mouse, touch
Keen Slider
The HTML touch slider carousel with the most native feeling
Stars: ✭ 3,097 (+651.7%)
Mutual labels:  touch, touch-events
React Cursor Position
A React component that decorates its children with mouse and touch coordinates relative to itself.
Stars: ✭ 136 (-66.99%)
Mutual labels:  mouse, touch
Swiper
Most modern mobile touch slider with hardware accelerated transitions
Stars: ✭ 29,519 (+7064.81%)
Mutual labels:  touch, touch-events
Vuetify Swipeout
👆 A swipe out example built with Vue CLI 3 + Vuetify + Swiper.
Stars: ✭ 117 (-71.6%)
Mutual labels:  touch, touch-events
gesto
You can set up drag, pinch events in any browser.
Stars: ✭ 47 (-88.59%)
Mutual labels:  touch, mouse
Pancake
Lightweight, Fast, Easy-to-use HTML5 2D game framework!
Stars: ✭ 79 (-80.83%)
Mutual labels:  touch, mouse

Creepyface · GitHub license npm version Build Coverage Status Follow on Twitter

The Creepyface logo with a background full of faces looking at the pointer

Creepyface is a little JavaScript library that makes your face look at the pointer (or dance 💃).

See it in action at creepyface.io and create your own one using the wizard.

If you use React, check out <Creepyface />. If you like fireflies, check out creepyface-firefly.

Example animated gif of a face looking at the pointer

Creepyface in the wild:

Usage

<script src="https://creepyface.io/creepyface.js"></script>

<img
  data-creepyface
  src="https://creepyface.io/img/0/serious"
  data-src-hover="https://creepyface.io/img/0/hover"
  data-src-look-0="https://creepyface.io/img/0/0"
  data-src-look-45="https://creepyface.io/img/0/45"
  data-src-look-90="https://creepyface.io/img/0/90"
  data-src-look-135="https://creepyface.io/img/0/135"
  data-src-look-180="https://creepyface.io/img/0/180"
  data-src-look-225="https://creepyface.io/img/0/225"
  data-src-look-270="https://creepyface.io/img/0/270"
  data-src-look-315="https://creepyface.io/img/0/315"
/>

Run this example on codepen.

Creepyface will automatically detect your image (thanks to the data-creepyface attribute) and make it look at the mouse or fingers depending on which device you are using.

You can add as many Creepyfaces as you want as long as they all have the data-creepyface attribute.

If you want to stop Creepyface on a given image:

creepyface.cancel(document.querySelector('img'))

Full list of data attributes

Name Description
data-creepyface Add this to automatically attach creepyface to your image when the page loads.
data-src-hover The URL of the image to use when the pointer is over your image.
data-src-look-<angle> The URL of the image to use when the pointer forms the specified angle (in degrees) with the center of your image. Add as many as you want.
data-timetodefault The amount of time (in milliseconds) after which the default src is restored if no pointer events are received. 1 second by default. 0 means it will never be restored (the image will always look at the pointer).
data-fieldofvision The angle (in degrees) inside which the pointer will be detected by a given direction. 150 by default.
data-points Optionally, a comma-separated list of point provider names to make your face look at things other than the pointer. See Super advanced usage for more information.

Advanced usage

For more advanced use cases Creepyface can also be set up via a programmatic API:

<img src="https://creepyface.io/img/0/serious" />
import creepyface from 'creepyface'

const img = document.querySelector('img')

const cancel = creepyface(img, {
  // Image URL to display on hover
  hover: 'https://creepyface.io/img/0/hover',
  // Each of the images looking at a given direction
  looks: [
    { angle: 0, src: 'https://creepyface.io/img/0/0' },
    { angle: 45, src: 'https://creepyface.io/img/0/45' },
    { angle: 90, src: 'https://creepyface.io/img/0/90' },
    { angle: 135, src: 'https://creepyface.io/img/0/135' },
    { angle: 180, src: 'https://creepyface.io/img/0/180' },
    { angle: 225, src: 'https://creepyface.io/img/0/225' },
    { angle: 270, src: 'https://creepyface.io/img/0/270' },
    { angle: 315, src: 'https://creepyface.io/img/0/315' }
  ],
  // Time (in ms) to restore the default image after the last input
  timeToDefault: 1000
  // The angle (in degrees) inside which the pointer will be detected
  fieldOfVision: 150
})

// at some point restore the original image and stop creepyface
cancel()

Run this example on codepen.

Super advanced usage

Creepyface will look at the pointer by default, however custom point providers can be defined.

For example, to make your face look at a random point every half a second you need to register a point provider:

import creepyface from 'creepyface'

creepyface.registerPointProvider('random', (consumer) => {
  const interval = setInterval(
    () =>
      consumer([
        Math.random() * window.innerWidth,
        Math.random() * window.innerHeight,
      ]),
    500
  )
  return () => {
    clearInterval(interval)
  }
})

and consume it using the data-points attribute:

<img
  data-creepyface
  data-points="random"
  src="https://creepyface.io/img/0/serious"
  data-src-hover="https://creepyface.io/img/0/hover"
  data-src-look-0="https://creepyface.io/img/0/0"
  data-src-look-45="https://creepyface.io/img/0/45"
  data-src-look-90="https://creepyface.io/img/0/90"
  data-src-look-135="https://creepyface.io/img/0/135"
  data-src-look-180="https://creepyface.io/img/0/180"
  data-src-look-225="https://creepyface.io/img/0/225"
  data-src-look-270="https://creepyface.io/img/0/270"
  data-src-look-315="https://creepyface.io/img/0/315"
/>

Run this example on codepen.

or pass it programmatically:

<img src="https://creepyface.io/img/0/serious" />
const img = document.querySelector('img')

creepyface(img, {
  points: 'random',
  hover: 'https://creepyface.io/img/0/hover',
  looks: [
    { angle: 0, src: 'https://creepyface.io/img/0/0' },
    { angle: 45, src: 'https://creepyface.io/img/0/45' },
    { angle: 90, src: 'https://creepyface.io/img/0/90' },
    { angle: 135, src: 'https://creepyface.io/img/0/135' },
    { angle: 180, src: 'https://creepyface.io/img/0/180' },
    { angle: 225, src: 'https://creepyface.io/img/0/225' },
    { angle: 270, src: 'https://creepyface.io/img/0/270' },
    { angle: 315, src: 'https://creepyface.io/img/0/315' },
  ],
})

Note: several point providers can work at the same time by using a comma-separated string like "random,pointer".

The following point providers are available out of the box:

  • pointer for both mouse and touch events. This is the default.
  • mouse just for mouse events.
  • finger just for touch events.

There are also external point providers:

  • 💃 dance to dance to the rythm of the music.
  • 🤳 tilt to stare at you when you tilt your phone.
  • 🐝 firefly to follow a moving firefly on the screen.

Developing

  • yarn && yarn build will set up the packages (using workspaces and Lerna) and run a required initial build.
  • yarn dev will spin up local servers for each of the packages.
  • yarn test will run the tests.

Contributing

Please feel free to create issues and / or submit pull requests. For the latter, test cases are very welcome.

License

MIT, see LICENSE for details.

Big Thanks

Cross-browser Testing Platform and Open Source ❤️ provided by Sauce Labs.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].