Giter VIP home page Giter VIP logo

face-cursor.js's Introduction

face-cursor.js

A little jQuery plugin to 3D transform elements relative to the cursor position

Demo

Demo: matthias-vogt.github.io/face-cursor.js

This is a jQuery plugin that adds CSS transform: rotate3d() based on the element's position relative to the mouse.

Usage

face-cursor.js depends on jQuery, so make sure you have that loaded. You can use it like this:

$(".some, .elements").faceCursor();
$(".some, .elements").faceCursor({
    options: "go here"
});

Install

<script src="jquery.min.js"></script>
<script src="face-cursor.js"></script>

For better loading performance, I'd recommend loading the script as non-critical content (by putting the <script> and <style> tags at the end of the body tag). Please also consider concatenating it with your other dependencies.

Install and update easily using npm:

npm install face-cursor --save

Options

{
    avertCursor: false,
    // whether the element should face away from the cursor instead of toward it
    perspective: "6rem", // CSS perspective for transforms
    cacheElementData: true // whether height, width and offset of the elements should be cached instead of recalculated each frame (if the elements move around or you want the effect to be consistent during browser resizing, disable)
}

Destroying

The plugin's instances can be destroyed on specific elements by doing

$elements.data("plugin_faceCursor").destroy();

…or, to destroy all instances:

$("*").filter(function() {
    return $(this).data("plugin_faceCursor") !== undefined
}).each(function() {
    $(this).data("plugin_faceCursor").destroy()
});

Browser support

This uses CSS3 transitions and window.requestAnimationFrame, so browser support is ie10+.

Contributing

You are very welcome to contribute! Please send pull requests and issues.

Feature requests

Feel free to post issues to ask for features.

TODO

  • support CommonJS and AMD
  • automatic testing

License

ISC

face-cursor.js's People

Contributors

matthias-vogt avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

face-cursor.js's Issues

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.