CSS3 Live version of the Click List item produces water ripple animation--the Jsoop object-oriented package version

Source: Internet
Author: User

1. HTML:

<! DOCTYPE html>
<meta charset= "UTF-8" >
<link rel= "stylesheet" href= "./css/reset.css"/>
<link rel= "stylesheet" href= "./css/animation.css"/>
<script type= "Text/javascript" src= "./js/jquery-1.10.2.min.js" ></script>
&LT;TITLE&GT;ANIMATION-CSS3 Animation </title>
<body>
<ul class= "Clear" id= "Animationlist" >
<li><span class= "Circle" ></span><a href= "#" > Home </a></li>
<li><span class= "Circle" ></span><a href= "#" > Todo file </a></li>
<li><span class= "Circle" ></span><a href= "#" > Files </a></li>
<li><span class= "Circle" ></span><a href= "#" > Access History </a></li>
</ul>
</body>
<script type= "Text/javascript" src= "Js/animation_oop.js" ></script>
<script type= "Text/javascript" >
var ani = new Circleopa (' animationlist ', ' circle-opacity ', ' #333 ', ' #2196f3 ');
Ani.init ();
</script>

2. CSS:

ul{width:300px;border:red;}
UL Li{width:300px;height:70px;line-height:70px;background: #fff; text-align:center;cursor:pointer;overflow:hidden ;}
UL Li a{font-weight:900;}
UL Li:hover a{
Color: #2196f3!important;
/*animation:circle-opacity 0.5s linear 0s 1;*/
/*-webkit-animation-fill-mode:forwards; Let the animation stop at the end of this property, */
/*animation-fill-mode:forwards;*/
}
UL Li A{position:relative;left: -50px;color: #333; top: -30px;}
. circle{background:transparent;border-radius:50%;width:70px;height:70px;display:inline-block;margin:0 Auto;}

@keyframes circle-opacity{
0% {
Background:rgba (192,225,250,0);
}
50% {
Transform:scale (4);
Background:rgba (192,225,250,1);
}
100% {
Transform:scale (16);
Background:rgba (192,225,250,0);
}
}
@-webkit-keyframes circle-opacity{/* compatible with Chrome's animation frame settings, to be called with the-webkit-animation property */
0% {
Background:rgba (192,225,250,0);
}
50% {
Transform:scale (4);
Background:rgba (192,225,250,1);
}
100% {
Transform:scale (16);
Background:rgba (192,225,250,0);
}
}

3, Jsoop version--Closure, object-oriented

/*
* Parameter Description:
* Context: Contextual, string form is ID, Object form is the DOM element that has been acquired
* Animationcss:css inside the encapsulated animation style class
* DefaultColor: Font color in default list items
* Activecolor: Font style values after sliding or clicking
*
* */

;(function () {
function Circleopa (context,animationcss,defaultcolor,activecolor) {
This.context = typeof Context = = ' string '? document.getElementById (context): context;
This.animationcss = Animationcss;
This.defaultcolor = DefaultColor;
This.activecolor = Activecolor;
}
Circleopa.prototype = {
Init:function () {
var that = this;//The This must be written here, relative to the INIT function's sub-onclick callback function to refer to the
var items = this.context.getElementsByTagName (' li ');
for (var i = 0; i < items.length; i++) {
Items[i].onclick = function () {//In the following event, this is a pointer to the source object that triggered the event Li element
alert (that); come in.
This.getelementsbytagname (' span ') [0].style.animation = that.animationcss+ ' 0.5s linear 0s 1 ';
This.getelementsbytagname (' span ') [0].style.webkitanimation = that.animationcss+ ' 0.5s linear 0s 1 ';
This.getelementsbytagname (' span ') [0].style.animationfillmode = ' forwards ';
$ (this). Siblings (). Children (' a '). css (' color ', that.defaultcolor);
$ (this). Children (' a '). css (' color ', that.activecolor);
That.clearanimation (this);
Alert (this.getelementsbytagname (' span ') [0].getattribute (' class '));//Popup Circle proof Gets the child element span
}
}
},
Clearanimation:function (self) {
var sid = Window.setinterval (function () {
Self.getelementsbytagname (' span ') [0].style.animation = ';
Self.getelementsbytagname (' span ') [0].style.webkitanimation = ';
Self.getelementsbytagname (' span ') [0].style.animationfillmode = ';
Sid = Window.clearinterval (SID);
},500);
}
}
Window. Circleopa = Circleopa;
}) (window);

CSS3 Live version of the Click List item produces water ripple animation--the Jsoop object-oriented package version

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.