Simple plugin in Javascript Vanilla to animate scrolling when you return to the top of the page

Download

npm install simplescrollup

or

yarn add simplescrollup

Quick start

1 Download simplescrollup.js .

	<script src="simplescrollup.js"></script>

Example

<html>
	<head>
	</head>
	<body>
		<!-- Your HTML content -->
		<script src="simplescrollup.js"></script>
	</body>

</html>

3 Add your button with this structure.

<a href="#up" class="simplescrollup__button simplescrollup__button--hide">Your text</a>

Example

<html>
	<head>
	</head>
	<body>
		<!-- Your HTML content -->
		<a href="#up" class="simplescrollup__button simplescrollup__button--hide">Your text</a>
		<script src="simplescrollup.js"></script>
	</body>

</html>

4 Add CSS.

.simplescrollup__button {
	position: fixed;
	bottom: 3rem;
	right: 3rem;
	transition: 1s all;
	z-index: 10000;
}
.simplescrollup__button--show {
	transform: translateX(0);
}
.simplescrollup__button--hide {
	transform: translateX(100px);
}

Example

<html>
	<head>
		<style>
			.simplescrollup__button {
				position: fixed;
				bottom: 3rem;
				right: 3rem;
				transition: 1s all;
				z-index: 10000;
			}
			.simplescrollup__button--show {
				transform: translateX(0);
			}
			.simplescrollup__button--hide {
				transform: translateX(100px);
			}
		</style>
	</head>
	<body>
		<!-- Your HTML content -->
		<a href="#up" class="simplescrollup__button simplescrollup__button--hide">Your text</a>
		<script src="simplescrollup.js"></script>
	</body>

</html>

5 Enjoy!!

Advance

You can control the duration and type of animation.

<a href="#up" duraction="1000" height-hide="100" easing="easeInOutQuad" class="simplescrollup__button simplescrollup__button--hide">Your text</a>

Demo

Press the right button.