html - Svg path animation on hover -


i want use transform property scale on svg on hover. when on hover svg path changes , animation takes place somewhere else instead of original path followed.

 html {     background-color: #28505d;   }   svg {     width: 50%;     float: left;   }   #plane:hover {     transform: scale(1.2, 1.2);   }   .planepath {     stroke: #d9dada;     stroke-width: .1%;     stroke-width: .5%;     stroke-dasharray: 1% 2%;     stroke-linecap: round;     fill: none;   }   .fil1 {     fill: #d9dada;   }   .fil2 {     fill: #c5c6c6;   }   .fil4 {     fill: #9d9e9e;   }   .fil3 {     fill: #aeafb0;   }
<svg viewbox="0 0 3387 1270">    <path id="planepath" class="planepath" d="m-226 626c439,4 636,-213 934,-225 755,-31 602,769 1334,658 562,-86 668,-698 266,-908 -401,-210 -893,189 -632,630 260,441 747,121 1051,91 360,-36 889,179 889,179" />    <g id="plane" transform="translate(-248,-306)">      <path id="note" fill="f23b3b" transform="translate(0,0)" d="m248.8,306.8c0,0-24-7-28.5,11c0,0-3,16,21,16.5c0,0,19.5,2.3,18.5-28.8s0-61.2,0-61.2s42,9,19,31.5c0,0,17-1,13.5-23c0,0-7.5-20-43-22l248.8,306.8z" />    </g>      <animatemotion xlink:href="#plane" dur="25s" repeatcount="indefinite" rotate="auto">      <mpath xlink:href="#planepath" />    </animatemotion>  </svg>

it's translate on #plane element causing problem. when scale, translate taken account in calculations, since need scale point. instead of applying transform #plane element, can apply note. when add scale on hover don't have worry translate part. see snippet, i've put scale 2, cause it's hard see 1.2 when it's not moving. can set whatever want, it'll scale without moving.

html {     background-color: #28505d;   }   svg {     width: 50%;     float: left;   }   #plane:hover {     transform: scale(2, 2) ;   }   .planepath {     stroke: #d9dada;     stroke-width: .1%;     stroke-width: .5%;     stroke-dasharray: 1% 2%;     stroke-linecap: round;     fill: none;   }   .fil1 {     fill: #d9dada;   }   .fil2 {     fill: #c5c6c6;   }   .fil4 {     fill: #9d9e9e;   }   .fil3 {     fill: #aeafb0;   }
<svg viewbox="0 0 3387 1270">    <path id="planepath" class="planepath" d="m-226 626c439,4 636,-213 934,-225 755,-31 602,769 1334,658 562,-86 668,-698 266,-908 -401,-210 -893,189 -632,630 260,441 747,121 1051,91 360,-36 889,179 889,179" />    <g id="plane" transform="translate(0,0)">      <path id="note" fill="f23b3b" transform="translate(-248,-306)" d="m248.8,306.8c0,0-24-7-28.5,11c0,0-3,16,21,16.5c0,0,19.5,2.3,18.5-28.8s0-61.2,0-61.2s42,9,19,31.5c0,0,17-1,13.5-23c0,0-7.5-20-43-22l248.8,306.8z" />    </g>      <animatemotion xlink:href="#plane" dur="25s" repeatcount="indefinite" rotate="auto">      <mpath xlink:href="#planepath" />    </animatemotion>  </svg>


Comments

Popular posts from this blog

get url and add instance to a model with prefilled foreign key :django admin -

css - Make div keyboard-scrollable in jQuery Mobile? -

ruby on rails - Seeing duplicate requests handled with Unicorn -