css - How do I animate this SVG clip-path hover effect? -


i trying animate transformation clip-path triangle square on hover state, can't seem working right.

i set demo @ http://jsfiddle.net/jcypykdk/ shows want do, minus animation.

html:

<svg id="svg-1" class="clip-svg" width="150" height="150">     <a xlink:href="http://google.com" class="svg-link">         <image id="img-1" class="svg-image" width="150" height="150" x="0" y="0" xlink:href="http://lorempixel.com/output/city-q-c-150-150-10.jpg" />          <defs>             <clippath id="clip-triangle">                 <polygon points="0,0 75,75 150,150 0,150" />             </clippath>         </defs>          <defs>             <clippath id="clip-square">                 <polygon points="0,0 0,150 150, 150 150, 0" />             </clippath>         </defs>     </a> </svg> 

css:

.svg-image, .svg-link {     clip-path: url(#clip-triangle); }  .svg-image:hover, .svg-link:hover {     clip-path: url(#clip-square); }  .svg-image, .svg-link {     transition: 0.5s ease 0.2s;     -moz-transition: 0.5s ease 0.2s;     -webkit-transition: 0.5s ease 0.2s; }  #img-1 {     display: block;     margin: auto; } 

i want triangle grow square on hover state, , shrink triangle when cursor leaves element.

i have tried many different techniques achieve @ point @ loss. appreciated.

this shows how begin smil solution work in chrome , firefox , possibly ie if use fakesmile. easing using calcmode="spline" haven't done here.

note in order keep - in id have escape \ sign in begin attribute.

.svg-image, .svg-link {      clip-path: url(#clip-triangle);  }
<svg id="svg-1" class="clip-svg" width="150" height="150">      <a xlink:href="http://google.com" class="svg-link">          <image id="img-1" class="svg-image" width="150" height="150" xlink:href="https://upload.wikimedia.org/wikipedia/mediawiki/a/a9/example.jpg" />  		             <defs>              <clippath id="clip-triangle">                  <polygon points="0,0 75,75 150,150 150,0">                      <animate begin="img\-1.mouseover" attributename="points" to="0,0 0,150 150,150 150, 0" dur="0.5s" fill="freeze"/>                      <animate begin="img\-1.mouseout" attributename="points" to="0,0 75,75 150,150 150,0" dur="0.5s" fill="freeze"/>                  </polygon>              </clippath>          </defs>      </a>  </svg>


Comments

Popular posts from this blog

javascript - Jquery show_hide, what to add in order to make the page scroll to the bottom of the hidden field once button is clicked -

javascript - Highcharts multi-color line -

javascript - Enter key does not work in search box -