Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using it's URL and the proper URL extention.

+ add another resource

JavaScript

Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <html>

<head>
	<title>slider</title>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />

</head>

<body>
<div style="
display: table;
width: 100%; height: 500px; background-color: #333;
	position: relative;
	z-index: 99;
	top: 0;
	">
	<div style="display: table-cell; text-align: center;">
		<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="1000" height="500">

			<path stroke="white" fill="none" id="bezier-path" stroke-width="1.2" d="M500,500 C500,224 500,151 500,0 " stroke-dasharray="4 2"/>

		</svg>
	</div>

</div>

	<div class="header-cont">

		<link rel="stylesheet" href="ad_branding_slidere4da.css?5">

		<section class="ad-slider" title="" style="height: 264px;">




			<a id="ad-slider-img" ondragstart="return false" class="ad-slider-img">
				<div style="background-color: #999;"></div>
			</a>



			<div id="ad-slider-roll" class="ad-slider-roll">
				<--drag and move-->
			</div>



		</section>

		<script type="text/javascript" src="ad_branding_sliderc81e.js?2"></script>

		<div>

		</div>
	</div>


</body>

</html>
              
            
!

CSS

              
                 
  body {
	background-color: #666666;
}


section.ad-slider {
	position: relative;
	z-index: 100;
	top: 0px;
	width: 100%;
	margin-bottom: -64px;
	display: block !important;
	visibility: visible !important;
	opacity: 1;
	text-align: center;
	position: relative;
	overflow: hidden;
	user-select: none;
	-webkit-user-select: none;
	-moz-user-select: none;
	min-width: 1200px;
	cursor: default;
}

section.ad-slider > a.ad-slider-img {
	display: block;
	position: absolute;
	width: 50%;
	height: 100%;
	overflow: hidden;
	cursor: default;
}

section.ad-slider > a.ad-slider-img > div {
	width: 100vw;
	height: 100%;
	min-width: 1200px;
	text-align: center;
	background-repeat: no-repeat;
	background-position: center;
}

section.ad-slider > section {
	position: absolute;
	width: 100%;
	bottom: 0;
	height: 64px;
	background: transparent url("../images/header_bg_white.png") repeat-x bottom left;
}

section.ad-slider > a.ad-link {
	position: absolute;
	width: 100%;
	height: 100%;
	cursor: default;
}

section.ad-slider > div.ad-slider-bg {
	position: absolute;
	width: 100vw;
	height: 100%;
}

section.ad-slider > div.ad-slider-roll {
	position: absolute;
	left: -moz-calc(50% - 17px);
	left: -webkit-calc(50% - 17px);
	left: calc(50% - 17px);
	width: 32px;
	height: 100%;
	cursor: col-resize;
}

section.ad-slider > div.ad-slider-roll > div {
	height: 90px;
	width: 3px;
	margin-left: 17px;
	background-color: white;
}

section.ad-slider > div.ad-slider-roll > div:last-child {
	height: 160px;
}

section.ad-slider > div.ad-slider-roll > i {
	display: block;
	width: 32px;
	height: 32px;
	border: 3px solid white;
	border-radius: 50%;
	position: relative;
	margin-top: -1px;
	margin-bottom: -1px;
	color: white;
	font-size: 13px;
	line-height: 34px;
	background-color: rgba(0, 0, 0, 0.3);
}

html, body, * {
	padding: 0;
}
              
            
!

JS

              
                (function() {
	var elem = document.getElementById('ad-slider-roll'),
		linia = document.getElementById('bezier-path'),
		img = document.getElementById('ad-slider-img'),
		startX = 0, initX = 17, goalX, goalAnimDuration = 15,
		curX = 0, maxDeltaX, isFree = true,
		animFromX, animTime = 0, backAnimDuration = 40,
		pi_half = Math.PI * 0.5,
		pi_x2 = Math.PI * 2,
		animRequested = false;

	var requestAnimationFrame = (function(){
		return window.requestAnimationFrame
		|| window.webkitRequestAnimationFrame
		|| window.mozRequestAnimationFrame
		|| function (callback) {
			window.setTimeout(callback, 1000 / 24);
		};
	})();

	elem.addEventListener('mousedown', function(e) {
		e = e || window.event;
		startX = e.clientX;
		var viewportSize = getViewportSize();
		maxDeltaX = viewportSize[0] / 2 - initX;
		isFree = false;
		animRequested = false;
		document.addEventListener('mousemove', onMove, true);
		document.addEventListener('mouseup', onUp, true);
	});

	function onMove(e) {
		e = e || window.event;
		goalX = initX + (e.clientX - startX);
		if (goalX < -maxDeltaX) {
			goalX = -maxDeltaX;
		} else if (goalX > maxDeltaX) {
			goalX = maxDeltaX;
		}
		animFromX = curX;
		animTime = 0;
		!animRequested && flyToRoll();
	}

	function onUp() {
		document.removeEventListener('mousemove', onMove, true);
		document.removeEventListener('mouseup', onUp, true);
		isFree = true;
		animRequested = false;
		animFromX = curX;
		backAnimDuration = ~~Math.max(20, Math.min(60, Math.abs(curX) / 10));
		animTime = 0;
		rollBack();
	}

	function updatePos() {
		img.style.cssText = 'width: -moz-calc(50% + ' + curX + 'px);' +
			'width: -webkit-calc(50% + ' + curX + 'px);' +
			'width: calc(50% + ' + curX + 'px);';
		elem.style.marginLeft = curX + 'px';


		linia.setAttribute("d", "M"+(curX+500).toFixed(0)+",500 C500,224 500,151 500,0 ");
	}

	function flyToRoll() {
		animRequested = false;
		if (isFree || curX == goalX) {
			return;
		}
		if (Math.abs(curX - goalX) < 0.1) {
			curX = goalX;
			updatePos();
			return;
		}
		animTime++;
		if (animTime > goalAnimDuration) {
			animTime = goalAnimDuration;
		}
		curX = interpolate('cubic', animTime, animFromX, goalX, goalAnimDuration);
		updatePos();
		animRequested = true;
		requestAnimationFrame(flyToRoll);
	}

	function rollBack() {
		animRequested = false;
		if (!isFree) {
			return;
		}
		animTime++;
		if (animTime > backAnimDuration) {
			animTime = backAnimDuration;
		}
		curX = interpolate(backAnimDuration < 30 ? 'exp' : 'elastic', animTime, animFromX, 0, backAnimDuration);
		updatePos();
		animRequested = true;
		requestAnimationFrame(rollBack);
	}

	function interpolate(method, current, from, to, duration) {
		var revert = (from > to), a = from;
		if (revert) {
			a = to;
			to = from - to;
			from = a;
		} else {
			to -= from;
		}
		switch (method) {
			default:
			case 'linear':
				a = to * current / duration + from;
				break;
			case 'cubic':
				a = to * ((current = current / duration - 1) * current * current  + 1) + from;
				break;
			case 'exp':
				a = (current == 0) ? from : to * Math.pow(2, 10 * (current / duration - 1)) + from - to * 0.001;
				if (current == duration) a = to + from;
				break;
			case 'sine':
				if (!revert) {
					a = to * Math.sin(current / duration * pi_half) + from;
				} else {
					a = -to * Math.cos(current / duration * pi_half) + to + from;
				}
				break;
			case 'bounce':
				if ((current /= duration) < (1 / 2.75)) {
					a = to * (7.5625 * current * current) + from;
				} else if (current < (2 / 2.75)) {
					a = to * (7.5625 * (current -= (1.5 / 2.75)) * current + .75) + from;
				} else if (current < (2.5 / 2.75)) {
					a = to * (7.5625 * (current -= (2.25 / 2.75)) * current + .9375) + from;
				} else {
					a = to * (7.5625 * (current -= (2.625 / 2.75)) * current + .984375) + from;
				}
				break;
			case 'elastic':
				if (current == 0) {
					a = from;
				} else {
					if ((current /= duration) == 1) {
						a = from + to;
					} else {
						var p = duration * .3;
						var s = p / 4;
						a = (to * Math.pow(2, -10 * current) * Math.sin((current * duration - s) * pi_x2 / p ) + to + from);
					}
				}
				break;
		}
		if (revert) {
			a = from + ((to + from) - a);
		}
		return a;
	}

	function getViewportSize() {
		var viewPortWidth;
		var viewPortHeight;

		if (typeof window.innerWidth != 'undefined') {
			viewPortWidth = window.innerWidth;
			viewPortHeight = window.innerHeight;
		} else if (typeof document.documentElement != 'undefined'
			&& typeof document.documentElement.clientWidth != 'undefined'
			&& document.documentElement.clientWidth != 0) {
			viewPortWidth = document.documentElement.clientWidth;
			viewPortHeight = document.documentElement.clientHeight;
		} else {
			viewPortWidth = document.getElementsByTagName('body')[0].clientWidth;
			viewPortHeight = document.getElementsByTagName('body')[0].clientHeight
		}
		return [viewPortWidth, viewPortHeight];
	}
})();
              
            
!
999px

Console