Last active
January 22, 2019 20:29
-
-
Save greystate/4e250fe82f93b9020f0bc0bba06c22d7 to your computer and use it in GitHub Desktop.
2DScroller Spike
This file contains hidden or 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
/** | |
* 2DScroller Spike | |
*/ | |
body { --value: 100; } | |
.item1, .item2 { box-sizing: border-box; } | |
section { | |
position: relative; | |
border: 4px solid #d0d; | |
width: 400px; | |
height: 100px; | |
left: 400px; | |
top: 20px; | |
overflow: hidden; | |
} | |
div[class^=item] { | |
width: 200px; height: 100px; | |
display: flex; | |
justify-content: center; | |
align-items: center; | |
color: #fff; | |
font-size: 3em; | |
} | |
div[class^=band] { position: absolute; } | |
.band1 { | |
z-index: 2; | |
background: #404; | |
width: 200px; | |
display: flex; | |
flex-direction: column; | |
--val1: calc(var(--value) * -1px); | |
top: var(--val1, 200px); | |
} | |
.band2 { | |
--val2: calc((0 - var(--value) + 200) * 1px); | |
left: var(--val2, 200px); | |
background: #8c8; | |
display: flex; | |
max-width: max-content; | |
} |
This file contains hidden or 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
<section> | |
<div class="band1"> | |
<div class="item1">[1]</div> | |
<div class="item1">[2]</div> | |
<div class="item1">[3]</div> | |
</div> | |
<div class="band2"> | |
<div class="item2">[A]</div> | |
<div class="item2">[B]</div> | |
<div class="item2">[C]</div> | |
</div> | |
</section> | |
<input type="range" min="0" max="600" value="0"> |
This file contains hidden or 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
const rng = document.querySelector('input[type=range]'); | |
rng.addEventListener('change', function(event) { | |
const val = rng.value; | |
document.body.style.setProperty('--value', val); | |
}); |
This file contains hidden or 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
{"view":"separate","fontsize":"100","seethrough":"","prefixfree":"1","page":"all"} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment