Git Product home page Git Product logo

hover-effect's Introduction

Hover effect

Javascript library to draw and animate images on hover.

DEMO

ARTICLE

Example

example 1 example 2

Basic usage

This helper needs Three.js and TweenMax to do the transition, so you need to include it before this little helper.

Then you only need a div element in HTML to start animating things with a piece of code like this:

<!-- Div to draw the effect -->
<div class="my-div"></div>

<!-- library needed -->
<script src="three.min.js"></script>
<script src="TweenMax.min.js"></script>

<script src="hover.js"></script>
<script>
    var myAnimation = new hoverEffect({
        parent: document.querySelector('.my-div'),
        intensity: 0.3,
        image1: 'images/myImage1.jpg',
        image2: 'images/myImage2.jpg',
        displacementImage: 'images/myDistorsionImage.png'
    });
</script>

Options

Mandatory parameters

Name Type Default Description
parent Dom element null The DOM element where the animation will be injected. The images of the animation will take the parent's size.
image1 Image null The first Image of the animation.
image2 Image null The second Image of the animation.
displacementImage Image null The Image used to do the transition between the 2 main images.

Optional parameters

Name Type Default Description
intensity Float 1 Used to determine the intensity of the distortion effect. 0 is no effect and 1 is full distortion.
intensity1 Float intensity Overrides the distortion intensity of the first image.
intensity2 Float intensity Overrides the distortion intensity of the second image.
angle Float Math.PI / 4 Angle of the distortion effect in Radians. Defaults to Pi / 4 (45 degrees).
angle1 Float angle Overrides the distortion angle for the first image.
angle2 Float -angle * 3 Overrides the distortion angle for the second image.
speedIn Float 1.6 Speed of the inbound animation (in seconds).
speedOut Float 1.2 Speed of the outbound animation (in seconds).
hover Boolean true if set to false the animation will not be triggered on hover (see next and previous function to interact)
easing String Expo.easeOut Easing of the transition, see greensock easing

Methods

Name Description
next Transition to the second image.
previous Transition to the first image.

Credits

Thanks to :

Made with it

Alex Brown demo

hover-effect's People

Contributors

akx avatar robin-dela avatar

Watchers

 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.