A jquery-based mouse click for a water wave effect

Source: Internet
Author: User

Today, for everyone, a mouse click that is implemented by jquery has a water-wave effect. Click on the page with the mouse, you can see the page constantly come forward water ripple effect. Then the ripples of water fade away. The effect is very good. Let's look at the following:

Online preview Source Download

The implemented code.

HTML code:

 <DivID= "Container">        <H1>Click or Touch the screen.</H1>        <P>Click as fast as you can.<em>Try it on a touchscreen-it ' s even more fun.</em></P></Div>

CSS code:

  * {User-select:None;cursor:default;}Body, HTML{Height:100%;font-family:Helvetica Neue,helvetica,arial,sans-serif;}H1, P{text-align:Center;position:relative;Z-index:1;}H1{padding:50px 0;margin:0 50px;font-size:30px;Line-height:30px;Font-weight: $;}P{font-size:14px;Font-weight: $;margin:0 50px;Color:#53646e;}p em{Color:#42a6df;}#container{position:relative;Height:100%;width:100%;Overflow:Hidden;}#container Button{padding:20px;Border:None;background:Transparent;Display:Block;position:relative;Z-index:3;margin:0 Auto;}. Dot{Height:2px;width:2px;Border-radius:100%;position:Absolute;Z-index:0;Animation:sploosh 3s cubic-bezier (0.165, 0.84, 0.44, 1);background:Transparent;}@keyframes Sploosh{0% {Box-shadow:0 0 0 0px rgba (166, 223, 0.7);background:Rgba (166, 223, 0.7); }100%{Box-shadow:0 0 0 300px rgba (166, 223, 0);background:Rgba (166, 223, 0); }}

JS Code:

$ (window). Ready (function() {setTimeout (function() {setTimeout (function () {                    $(' #container '). Append (' <div class= "dot" style= "top:50%;left:50%;" ></div> ')                }, 900); SetTimeout (function () {                    $(' #container '). Append (' <div class= "dot" style= "top:50%;left:50%;" ></div> ')                }, 600); SetTimeout (function () {                    $(' #container '). Append (' <div class= "dot" style= "top:50%;left:50%;" ></div> ')                }, 300); SetTimeout (function () {                    $(' #container '). Append (' <div class= "dot" style= "top:50%;left:50%;" ></div> ')                }, 0); SetTimeout (function () {                    $(' #container dot '). Remove (); }, 2900); }, 1500);        }); //Click Animation        if(Modernizr.touch) {$ (' #container '). On (' Touchstart ',function(e) {varleft = E.originalevent.touches[0].pagex; vartop = E.originalevent.touches[0].pagey; $( This). Append (' <div class= ' dot ' style= ' top: ' + top + ' Px;left: ' + left + ' px; " ></div> ') SetTimeout (function () {                    $(' #container. Dot:first-of-type '). Remove (); }, 3000);            }); Document.body.addEventListener (' Touchmove ',function(e) {e.preventdefault ();        }); } Else {            $(' #container '). On (' MouseDown ',function(e) {varleft =E.pagex; vartop =E.pagey; $( This). Append (' <div class= ' dot ' style= ' top: ' + top + ' Px;left: ' + left + ' px; " ></div> ') SetTimeout (function () {                    $(' #container. Dot:first-of-type '). Remove (); }, 3000);        }); } //@ sourceurl=pen.js

Note: This article Love programming original article, reproduced please specify the original address: http://www.w2bc.com/Article/6909

A jquery-based mouse click for a water wave effect

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.