Animated Bar

Why is this so choppy?

by Rynne Cowham

HTML

<html>
<head>
<script>
  function setCookie(name,value,days) {
		var date = new Date();
    var expires;
		date.setTime(date.getTime()+(days*24*60*60*1000));
	if (days) 
		expires = "; expires="+date.toGMTString();
	else 
		expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
	document.getElementById("urgentmsgbar").style.display = "none";
	var contentStart = document.getElementById("wrapper");
		contentStart.style.animation = "slide 0s";	// immediate reset to top
		contentStart.style.marginTop = "0px";
		contentStart.style.top = "0";
}

function getCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0; i < ca.length; i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) {
			return c.substring(nameEQ.length,c.length);
		}
	}
}

function checkForCookie(name) {
	var alertBar = document.getElementById("urgentmsgbar");
	var contentStart = document.getElementById("wrapper");
	var isset = getCookie('_cookieMsgRead');
	if (isset) {
		contentStart.style.animation = "slide 0s";
		contentStart.style.marginTop = "0px";
		contentStart.style.top = "0";
		alertBar.style.display = "none";
	}
	else {
	document.getElementById("urgentmsgbar").style.animation = "slide 4s ease-in-out 1s forwards";
	document.getElementById("wrapper").style.animation = "movebody 3s ease-in-out 2s forwards";		
	}
}

function deleteCookie(name) {
	setCookie(name,' ',-1);
}
window.onload = function() {
	checkForCookie('_cookieMsgRead');
}
</script>
</head>

<body>
<div class="cc-window cc-banner cc-top" id="urgentmsgbar"><a id="closebutton" class="btn btn-close btn-lg" href="javascript:setCookie('_cookieMsgRead','msgclosed','0.5');">&times;</a><span class="cc-message">
<p class="cc-header">Emergency Alert</p>
<br>Air Quality Index Hazardous Levels&nbsp;&raquo;</span>
</div>
	<div class="content" id="wrapper">
		<h1>title</h1>
		<p>some other content</p>	<p>some other content</p>	<p>some other...

CSS

@keyframes slide {
  0% {
  	display: none;
  	height: 0;
    left: 0;
    margin-top: -22px;
    opacity: 0;
    top: -100px;
    visibility: hidden;
  }
  100% {
  	display: block;
  	height: auto;
    left: 0;
    margin-top: 0;
    opacity: 1;
    top: 0;
    visibility: visible;
  }
}
@keyframes movebody {
  0% {
    left: 0;
    margin-top: 0;
    top: 0;
  }
  100% {
    left: 0;
    margin-top: 88px;
    position: absolute;
    top: 0;
  }
}
.cc-window.cc-banner {
  align-items: center;
  flex-direction: row;
  padding: 5px 0;
  width: 100%;
}
.cc-banner.cc-top {
	background-color: #ff0000;
	border-top: 6px solid #000000;
	border-bottom: 6px solid #000000;
	color: #ffffff;
	clear: both;
	font-family: verdana, sans-serif;
	height: 0;
  left: 0;
  opacity: 0;
  right: 0;
  top: 0;
  position: absolute;
  z-index: 9999;
}
.cc-message {
  color: #ffffff;
	display: block;
	font-size: 14px;
	line-height: 1.75;
	margin: 6px auto 4px;
	padding: 0 10px;
  text-align: center;
}
.cc-message a:link, .cc-message a:visited,
.cc-message a:hover, .cc-message a:active {
  color: #ffffff !important;
	text-decoration: none;
	padding: 4px;
}
.cc-message a:hover, .cc-message a:active {
	color: #000000;
	text-decoration: underline;
}
.cc-header { font-size: 18px; }
.btn-close, #closebutton {
	background: #ffffff !important;
	border: 1px solid #000000;
	border-radius: 2px;
	color: #000000 !important;
	float: right;
	font-size: 16px;
	font-weight: bold;
  margin: 10px;
  padding: 4px 8px;
  text-decoration: none;
}
#closebutton:hover, .btn-close:hover, 
#closebutton:active, .btn-close:active {
	border-color: #ffffff;
	color: #f47920;
}

@media only screen and (max-width: 767px) {
	.cc-message { line-height: 0; }
	.btn-close, #closebutton {
      font-size: 16px;
      padding: 10px 12px;
  }
    #closebutton, span.mobileview {
      display: block;
      clear: both;
  }
}