Created
November 13, 2013 17:08
-
-
Save anonymous/7452632 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
article { | |
-webkit-column-count:5; | |
-webkit-column-width: 100%; | |
-webkit-column-rule: 1px solid red; | |
width: 500% | |
} | |
#container { | |
overflow: auto; | |
height: 150px; | |
width: 100%; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset=utf-8 /> | |
<title>JS Bin</title> | |
</head> | |
<body> | |
<div id='container'> | |
<article> | |
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nunc libero magna, venenatis quis aliquet et, | |
rutrum in augue. Donec vel tempor dolor. Donec volutpat fringilla porta. Suspendisse non nulla tortor. | |
Quisque commodo ornare mi, sit amet aliquet justo bibendum non. Integer bibendum convallis sapien, sit | |
amet tincidunt orci placerat in. Integer vitae consequat augue. | |
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nunc libero magna, venenatis quis aliquet et, | |
rutrum in augue. Donec vel tempor dolor. Donec volutpat fringilla porta. Suspendisse non nulla tortor. | |
Quisque commodo ornare mi, sit amet aliquet justo bibendum non. Integer bibendum convallis sapien, sit | |
amet tincidunt orci placerat in. Integer vitae consequat augue. | |
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nunc libero magna, venenatis quis aliquet et, | |
rutrum in augue. Donec vel tempor dolor. Donec volutpat fringilla porta. Suspendisse non nulla tortor. | |
Quisque commodo ornare mi, sit amet aliquet justo bibendum non. Integer bibendum convallis sapien, sit | |
amet tincidunt orci placerat in. Integer vitae consequat augue. | |
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nunc libero magna, venenatis quis aliquet et, | |
rutrum in augue. Donec vel tempor dolor. Donec volutpat fringilla porta. Suspendisse non nulla tortor. | |
Quisque commodo ornare mi, sit amet aliquet justo bibendum non. Integer bibendum convallis sapien, sit | |
amet tincidunt orci placerat in. Integer vitae consequat augue. | |
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nunc libero magna, venenatis quis aliquet et, | |
rutrum in augue. Donec vel tempor dolor. Donec volutpat fringilla porta. Suspendisse non nulla tortor. | |
Quisque commodo ornare mi, sit amet aliquet justo bibendum non. Integer bibendum convallis sapien, sit | |
amet tincidunt orci placerat in. Integer vitae consequat augue. | |
= | |
</article> | |
</div> | |
</body> | |
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var __scrolled, | |
$container = document.querySelector('#container'), | |
$article = document.querySelector('article') | |
; | |
$container | |
.addEventListener('scroll', deferPosition, false); | |
document.body.addEventListener('mouseup', function(){ | |
__scrolled && doPosition(); | |
}, true); | |
function deferPosition(){ | |
__scrolled = true; | |
} | |
function doPosition(){ | |
__scrolled = false; | |
var vw = $container.offsetWidth, | |
cw = $article.offsetWidth / 5, | |
width = $article.offsetWidth, | |
left = $container.scrollLeft, | |
index = Math.round(left / cw) | |
; | |
$container.scrollLeft = cw * index; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment