Skip to content

Instantly share code, notes, and snippets.

@enricopolanski
Created February 19, 2018 12:13
Show Gist options
  • Save enricopolanski/0737c4224845bf76b63323c78fcc59ac to your computer and use it in GitHub Desktop.
Save enricopolanski/0737c4224845bf76b63323c78fcc59ac to your computer and use it in GitHub Desktop.
function elementTransition(element, distX){
document.styleSheets[0].insertRule(".transitioning{ transition: transform 100ms linear;"+
"transform: translate(" + distX + "px, 0px);}");
element.classList.add("transitioning");
window.setTimeout((element)=>{
if (distX<0){
element.appendBefore(element.previousElementSibling);
element.previousElementSibling.removeEventListener("mousemove", passedFunction);
}
}, 100);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment