javascript - Transition not smooth on width -


so have envelope image , letter image , want letter smoothly transition out of envelope onmouseover , want letter smoothly transition place onmouseout. first mouseover perfect, envelope slides -400px width in order reveal letter @ 1 second transition, onmouseout, envelope harshly snaps place , have no idea why. also, additional mouseovers after mouseout, harshly snaps both onmouseover , onmouseout events. here code:

<!doctype html>      <html lang='en-us'>      <head>      <title>test animation</title>      <style>      	.displaynow {      		display: flex;      		flex-direction: row;      		justify-content: flex-end;      		position: relative;      	}      	.letter {      		position: absolute;      	}      	.envelope {      		position: absolute;      		transition: width 1s ease-in-out;      		transition-timing-function: linear;      		-webkit-transition: 1s ease-in-out;      		-webkit-transition-timing-function: linear;      	}      </style>      <script>      function moveout() {      	var cssstring = "margin-left:-400px;";      	document.getelementbyid('envelope').style.csstext=cssstring;      }      function movein() {      	var cssstring = "margin-left:auto;";      	document.getelementbyid('envelope').style.csstext=cssstring;      }      </script>      </head>      <body>      <div class='displaynow'>      <!-- letter -->      <img src='letter.png' class='letter' id='letter' onmouseover='moveout()' onmouseout='movein()' alt='letter'>      <!-- envelope -->      <img src='envelope.png' class='envelope' id='envelope' onmouseover='moveout()' onmouseout='movein()' alt='envelope'>            </div>      </body>      </html>

i have tried :hover selector opposed onmouseout/in javascript event produced same result.

instead of setting margin-left auto, set 0 (or wherever else it's supposed sit at)

i believe css3 transitions not know how handle auto settings. apply transitionable element can set auto. have ran problem several times when trying transition heights , widths.

as far issue of snapping both ways after initial transition, i'm not sure if related margin-left:auto issue or not willing bet fix it


Comments

Popular posts from this blog

ubuntu - PHP script to find files of certain extensions in a directory, returns populated array when run in browser, but empty array when run from terminal -

php - How can i create a user dashboard -

javascript - How to detect toggling of the fullscreen-toolbar in jQuery Mobile? -