content logo

React Popups:

Animating React Popup with Float in and Zoom Effects

The pop-up displayed in this post will run along with the animation. Clicking on the button in the middle of the pop-up page opens from the center to the surroundings. Pop-up has sharp corners. The close button as well as other buttons in this pop-up are green. The title and text of the pop-up are black. To the right of the pop-up is a photo.

#

React Popup Animation

#

Popup Zoom Effect

#

Popop Float in Effect

#

CSS Dynamic Popup

<!-- This script got from frontendfreecode.com -->
<div id="app"></div><a style="font-size: 8pt; text-decoration: none" target="_blank" href="http://frontendfreecode.com">Free Frontend</a>
                                                                            
.hidden {
	opacity: 0;
}
* {
	box-sizing: border-box;
	font-family: "Raleway", sans-serif;
	font-weight: 500;
	color: #222;
}
body {
	width: 100%;
	height: 100vh;
	background: #16a085;
	background: #1abc9c;
	background: -moz-linear-gradient(top, #1abc9c 0%, #16a085 100%);
	background: -webkit-linear-gradient(top, #1abc9c 0%, #16a085 100%);
	background: linear-gradient(to bottom, #1abc9c 0%, #16a085 100%);
	filter: progid:DXImageTransform.Microsoft.gradient( startColorstr="#1abc9c", endColorstr="#16a085", GradientType=0);
	overflow: hidden;
}
.opener {
	position: absolute;
	top: 0;
	bottom: 0;
	left: 0;
	right: 0;
	margin: auto;
	width: 250px;
	height: 80px;
	color: #16a085;
	background-color: white;
	border: none;
	font-size: 2em;
	font-weight: 700;
	z-index: 20;
}
#above {
	z-index: 20;
}
#below {
	z-index: 0;
}
::-webkit-scrollbar {
	width: 0px;
	background: transparent;
}
::-webkit-scrollbar-thumb {
	background: #FF0000;
}
.opener:hover {
	cursor: pointer;
}
#pop-up {
	position: absolute;
	top: 0;
	bottom: 0;
	left: 0;
	right: 0;
	margin: auto;
	-webkit-box-shadow: 0px 0px 59px 5px rgba(0, 0, 0, 0.48);
	-moz-box-shadow: 0px 0px 59px 5px rgba(0, 0, 0, 0.48);
	box-shadow: 0px 0px 59px 5px rgba(0, 0, 0, 0.48);
	width: 90%;
	opacity: 0;
	max-height: 450px;
	max-width: 1000px;
	height: 90%;
	background-color: white;
	z-index: 10;
	overflow: hidden;
}
#pop-up .border-overlay {
	position: absolute;
	top: 0;
	bottom: 0;
	left: 0;
	right: 0;
	margin: auto;
	width: 100%;
	height: 100%;
}
#pop-up .border-overlay .white {
	width: 100%;
	height: 100%;
	border: 20px solid white;
}
#pop-up .photo {
	display: inline-block;
	float: left;
	width: 50%;
	height: 100%;
	overflow: auto;
	object-position: center;
	object-size: cover;
}
#pop-up .photo img {
	max-height: 100%;
}
#pop-up .text {
	display: inline-block;
	float: left;
	width: 50%;
	height: 90%;
	margin: 2.5% 0;
	padding: 0 40px;
}
#pop-up .text h1 {
	font-weight: 900;
	font-size: 4vw;
	margin: 0;
}
#pop-up .text p {
	width: 90%;
	font-weight: 500;
	font-size: 1.2em;
	line-height: 1.8em;
}
#pop-up .text button {
	background-color: #16a085;
	border: none;
	font-size: 1.7em;
	margin: 20px 0;
	padding: 10px 40px;
	color: white;
	cursor: pointer;
}
#pop-up .text .close {
	position: absolute;
	top: -10px;
	right: 40px;
	width: auto;
	font-weight: 700;
	font-size: 2em;
	color: white;
	cursor: pointer;
}
#pop-up hr {
	width: 40%;
	height: 10px;
	margin: 10px auto 30px 0;
	border: none;
	outline: none;
	background-color: #333;
	color: grey;
}
#innerPopUp {
	height: 100%;
	overflow: auto;
	opacity: 0;
}
.fade-in {
	animation: fadeIn 1.3s ease forwards 1s;
}
.fade-out {
	animation: fadeOut 1.3s ease forwards;
}
.animate-in {
	animation: popIn 1.3s cubic-bezier(0.87, -0.41, 0.19, 1.22) forwards;
}
.animate-out {
	animation: popOut 1.3s cubic-bezier(0.87, -0.41, 0.19, 1.22) forwards;
}
@keyframes fadeIn {
	from {
		transform: translateY(-20px);
		opacity: 0;
	}
	to {
		transform: translateY(0px);
		opacity: 1;
	}
}
@keyframes popIn {
	0% {
		opacity: 0;
		transform: scale(0, 0);
	}
	60% {
		opacity: 1;
		transform: scale(1, 1);
	}
	100% {
		opacity: 1;
		transform: scale(1, 1);
	}
}
@keyframes popOut {
	0% {
		z-index: 100;
		opacity: 1;
		transform: scale(1, 1);
	}
	60% {
		z-index: 0;
		opacity: 0.1;
		transform: scale(0.001, 0.001);
	}
	100% {
		opacity: 0;
		transform: scale(0, 0);
	}
}
@-webkit-keyframes $animationName {
	0% {
		opacity: 0;
		transform: scale(0, 0);
	}
	100% {
		opacity: 1;
		transform: scale(1, 1);
	}
}
@-moz-keyframes $animationName {
	0% {
		opacity: 0;
		transform: scale(0, 0);
	}
	100% {
		opacity: 1;
		transform: scale(1, 1);
	}
}
@-o-keyframes $animationName {
	0% {
		opacity: 0;
		transform: scale(0, 0);
	}
	100% {
		opacity: 1;
		transform: scale(1, 1);
	}
}
@keyframes $animationName {
	0% {
		opacity: 0;
		transform: scale(0, 0);
	}
	100% {
		opacity: 1;
		transform: scale(1, 1);
	}
}
class PopUp extends React.Component {
  constructor() {
    super();
    this.state = {
      animation_name: '',
      depth: '',
      fade: '' };
  }
  closePopUp() {
    this.setState({ animation_name: 'animate-out' });
    this.setState({ depth: 'above' });
    this.setState({ fade: 'fade-out' });
  }
  openPopUp() {
    this.setState({ animation_name: 'animate-in' });
    this.setState({ depth: 'below' });
    this.setState({ fade: 'fade-in' });
  }
  render() {
    return /*#__PURE__*/(
      React.createElement("div", null, /*#__PURE__*/
      React.createElement("button", { className: "opener", id: this.state.depth, onClick: this.openPopUp.bind(this) }, "Open Pop Up"), /*#__PURE__*/
      React.createElement("section", { id: "pop-up", className: this.state.animation_name }, /*#__PURE__*/
      React.createElement("div", { id: "innerPopUp", className: this.state.fade }, /*#__PURE__*/
      React.createElement("div", { className: "border-overlay" }, /*#__PURE__*/
      React.createElement("div", { className: "white" }), /*#__PURE__*/
      React.createElement("div", { className: "black" })), /*#__PURE__*/
      React.createElement("div", { className: "text" }, /*#__PURE__*/
      React.createElement("h1", null, "Hey there"), /*#__PURE__*/
      React.createElement("hr", null), /*#__PURE__*/
      React.createElement("button", { className: "close", onClick: this.closePopUp.bind(this) }, "X "), /*#__PURE__*/
          React.createElement("p", null, "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. "), /*#__PURE__*/
      React.createElement("button", null, "Check it out")), /*#__PURE__*/
      React.createElement("div", { className: "photo" }, /*#__PURE__*/
      React.createElement("img", { src: "https://static.pexels.com/photos/57905/pexels-photo-57905.jpeg" }))))));
  }}
ReactDOM.render( /*#__PURE__*/
React.createElement(PopUp, null),
document.getElementById('app'));
<script src='https://cdnjs.cloudflare.com/ajax/libs/react/15.4.2/react.min.js'></script>
<script src='https://cdnjs.cloudflare.com/ajax/libs/react/15.4.2/react-dom.min.js'></script>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<!-- This script got from frontendfreecode.com -->

<script src='https://cdnjs.cloudflare.com/ajax/libs/react/15.4.2/react.min.js'></script>
<script src='https://cdnjs.cloudflare.com/ajax/libs/react/15.4.2/react-dom.min.js'></script>
<style>
.hidden {
	opacity: 0;
}
* {
	box-sizing: border-box;
	font-family: "Raleway", sans-serif;
	font-weight: 500;
	color: #222;
}
body {
	width: 100%;
	height: 100vh;
	background: #16a085;
	background: #1abc9c;
	background: -moz-linear-gradient(top, #1abc9c 0%, #16a085 100%);
	background: -webkit-linear-gradient(top, #1abc9c 0%, #16a085 100%);
	background: linear-gradient(to bottom, #1abc9c 0%, #16a085 100%);
	filter: progid:DXImageTransform.Microsoft.gradient( startColorstr="#1abc9c", endColorstr="#16a085", GradientType=0);
	overflow: hidden;
}
.opener {
	position: absolute;
	top: 0;
	bottom: 0;
	left: 0;
	right: 0;
	margin: auto;
	width: 250px;
	height: 80px;
	color: #16a085;
	background-color: white;
	border: none;
	font-size: 2em;
	font-weight: 700;
	z-index: 20;
}
#above {
	z-index: 20;
}
#below {
	z-index: 0;
}
::-webkit-scrollbar {
	width: 0px;
	background: transparent;
}
::-webkit-scrollbar-thumb {
	background: #FF0000;
}
.opener:hover {
	cursor: pointer;
}
#pop-up {
	position: absolute;
	top: 0;
	bottom: 0;
	left: 0;
	right: 0;
	margin: auto;
	-webkit-box-shadow: 0px 0px 59px 5px rgba(0, 0, 0, 0.48);
	-moz-box-shadow: 0px 0px 59px 5px rgba(0, 0, 0, 0.48);
	box-shadow: 0px 0px 59px 5px rgba(0, 0, 0, 0.48);
	width: 90%;
	opacity: 0;
	max-height: 450px;
	max-width: 1000px;
	height: 90%;
	background-color: white;
	z-index: 10;
	overflow: hidden;
}
#pop-up .border-overlay {
	position: absolute;
	top: 0;
	bottom: 0;
	left: 0;
	right: 0;
	margin: auto;
	width: 100%;
	height: 100%;
}
#pop-up .border-overlay .white {
	width: 100%;
	height: 100%;
	border: 20px solid white;
}
#pop-up .photo {
	display: inline-block;
	float: left;
	width: 50%;
	height: 100%;
	overflow: auto;
	object-position: center;
	object-size: cover;
}
#pop-up .photo img {
	max-height: 100%;
}
#pop-up .text {
	display: inline-block;
	float: left;
	width: 50%;
	height: 90%;
	margin: 2.5% 0;
	padding: 0 40px;
}
#pop-up .text h1 {
	font-weight: 900;
	font-size: 4vw;
	margin: 0;
}
#pop-up .text p {
	width: 90%;
	font-weight: 500;
	font-size: 1.2em;
	line-height: 1.8em;
}
#pop-up .text button {
	background-color: #16a085;
	border: none;
	font-size: 1.7em;
	margin: 20px 0;
	padding: 10px 40px;
	color: white;
	cursor: pointer;
}
#pop-up .text .close {
	position: absolute;
	top: -10px;
	right: 40px;
	width: auto;
	font-weight: 700;
	font-size: 2em;
	color: white;
	cursor: pointer;
}
#pop-up hr {
	width: 40%;
	height: 10px;
	margin: 10px auto 30px 0;
	border: none;
	outline: none;
	background-color: #333;
	color: grey;
}
#innerPopUp {
	height: 100%;
	overflow: auto;
	opacity: 0;
}
.fade-in {
	animation: fadeIn 1.3s ease forwards 1s;
}
.fade-out {
	animation: fadeOut 1.3s ease forwards;
}
.animate-in {
	animation: popIn 1.3s cubic-bezier(0.87, -0.41, 0.19, 1.22) forwards;
}
.animate-out {
	animation: popOut 1.3s cubic-bezier(0.87, -0.41, 0.19, 1.22) forwards;
}
@keyframes fadeIn {
	from {
		transform: translateY(-20px);
		opacity: 0;
	}
	to {
		transform: translateY(0px);
		opacity: 1;
	}
}
@keyframes popIn {
	0% {
		opacity: 0;
		transform: scale(0, 0);
	}
	60% {
		opacity: 1;
		transform: scale(1, 1);
	}
	100% {
		opacity: 1;
		transform: scale(1, 1);
	}
}
@keyframes popOut {
	0% {
		z-index: 100;
		opacity: 1;
		transform: scale(1, 1);
	}
	60% {
		z-index: 0;
		opacity: 0.1;
		transform: scale(0.001, 0.001);
	}
	100% {
		opacity: 0;
		transform: scale(0, 0);
	}
}
@-webkit-keyframes $animationName {
	0% {
		opacity: 0;
		transform: scale(0, 0);
	}
	100% {
		opacity: 1;
		transform: scale(1, 1);
	}
}
@-moz-keyframes $animationName {
	0% {
		opacity: 0;
		transform: scale(0, 0);
	}
	100% {
		opacity: 1;
		transform: scale(1, 1);
	}
}
@-o-keyframes $animationName {
	0% {
		opacity: 0;
		transform: scale(0, 0);
	}
	100% {
		opacity: 1;
		transform: scale(1, 1);
	}
}
@keyframes $animationName {
	0% {
		opacity: 0;
		transform: scale(0, 0);
	}
	100% {
		opacity: 1;
		transform: scale(1, 1);
	}
}
</style>

</head>
<body>
<div id="app"></div><div id="bcl"><a style="font-size:8pt;text-decoration:none;" href="http://www.devanswer.com">Free Frontend</a></div>
<script>
class PopUp extends React.Component {
  constructor() {
    super();
    this.state = {
      animation_name: '',
      depth: '',
      fade: '' };
  }
  closePopUp() {
    this.setState({ animation_name: 'animate-out' });
    this.setState({ depth: 'above' });
    this.setState({ fade: 'fade-out' });
  }
  openPopUp() {
    this.setState({ animation_name: 'animate-in' });
    this.setState({ depth: 'below' });
    this.setState({ fade: 'fade-in' });
  }
  render() {
    return /*#__PURE__*/(
      React.createElement("div", null, /*#__PURE__*/
      React.createElement("button", { className: "opener", id: this.state.depth, onClick: this.openPopUp.bind(this) }, "Open Pop Up"), /*#__PURE__*/
      React.createElement("section", { id: "pop-up", className: this.state.animation_name }, /*#__PURE__*/
      React.createElement("div", { id: "innerPopUp", className: this.state.fade }, /*#__PURE__*/
      React.createElement("div", { className: "border-overlay" }, /*#__PURE__*/
      React.createElement("div", { className: "white" }), /*#__PURE__*/
      React.createElement("div", { className: "black" })), /*#__PURE__*/
      React.createElement("div", { className: "text" }, /*#__PURE__*/
      React.createElement("h1", null, "Hey there"), /*#__PURE__*/
      React.createElement("hr", null), /*#__PURE__*/
      React.createElement("button", { className: "close", onClick: this.closePopUp.bind(this) }, "X "), /*#__PURE__*/
          React.createElement("p", null, "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. "), /*#__PURE__*/
      React.createElement("button", null, "Check it out")), /*#__PURE__*/
      React.createElement("div", { className: "photo" }, /*#__PURE__*/
      React.createElement("img", { src: "https://static.pexels.com/photos/57905/pexels-photo-57905.jpeg" }))))));
  }}
ReactDOM.render( /*#__PURE__*/
React.createElement(PopUp, null),
document.getElementById('app'));
</script>

</body>
</html>
Preview