lundi 13 juin 2016

Hold Hover event

I;m using this hover-css-items to animate menu.

Particularly : Background Transitions > Swipe to right.

enter image description here

I need to hold the animation like in pic 2 while i leave the button (By default it will come to image 1 if i hover out).

Initially the link is red... and on hover it animates to green ... and on hover out it comes back to red. I need to keep the link to green even if i hover out ... and externally trigger to go back to red.. when required by changing class.

.hvr-sweep-to-right {
  -webkit-transform: translateZ(0);
  transform: translateZ(0);
  box-shadow: 0 0 1px rgba(0, 0, 0, 0);
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
  -moz-osx-font-smoothing: grayscale;
  position: relative;
  -webkit-transition-property: color;
  transition-property: color;
  -webkit-transition-duration: 0.3s;
  transition-duration: 0.3s;
}
.hvr-sweep-to-right:before {
  content: "";
  position: absolute;
  z-index: -1;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: green;
  -webkit-transform: scaleX(0);
  transform: scaleX(0);
  -webkit-transform-origin: 0 50%;
  transform-origin: 0 50%;
  -webkit-transition-property: transform;
  transition-property: transform;
  -webkit-transition-duration: 0.3s;
  transition-duration: 0.3s;
  -webkit-transition-timing-function: ease-out;
  transition-timing-function: ease-out;
}
.hvr-sweep-to-right:hover, .hvr-sweep-to-right:focus, .hvr-sweep-to-right:active {
  color: white;
}
.hvr-sweep-to-right:hover:before, .hvr-sweep-to-right:focus:before, .hvr-sweep-to-right:active:before {
  -webkit-transform: scaleX(1);
  transform: scaleX(1);
}

.try{
	height:80px;
	width:200px;
	background:red;
}
<ul>
		<li class="try hvr-sweep-to-right"> Link 1</li>
		
		<li class="try hvr-sweep-to-right"> Link 2 </li>
	</ul>

Aucun commentaire:

Enregistrer un commentaire