Created
November 9, 2016 21:02
-
-
Save tkrugg/c74cd27aa844fdf45ca20051f0a4fbf4 to your computer and use it in GitHub Desktop.
rWOvvo
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
| <div class="square"></div> | |
| <div class="square"></div> | |
| <div class="square"></div> | |
| <div class="square small"></div> | |
| <br> | |
| <div class="square tightened-down"></div> | |
| <br> | |
| <div class="square invisible tightened-up tightened-down"></div> | |
| <div class="square tightened-up tightened-down"></div> | |
| <div class="square invisible tightened-up tightened-down"></div> | |
| <br> | |
| <div class="square invisible tightened-up"></div> | |
| <div class="square invisible tightened-up"></div> | |
| <div class="square tightened-up"></div> | |
| <br> | |
| <div class="square"></div> | |
| <div class="square"></div> | |
| <div class="square"></div> | |
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
| var bigSquares = $(".square:not(.small):not(.invisible)") | |
| var clicked = []; | |
| bigSquares.click(function() { | |
| $(this).toggleClass("blue"); | |
| if ($(this).hasClass("blue")) { | |
| clicked.push(this); | |
| } else { | |
| var that = this; | |
| clicked = clicked.filter(function(elem) { | |
| return elem === that; | |
| }); | |
| } | |
| if (clicked.length === bigSquares.length) { // if all big squares were clicked | |
| unclickAll(clicked) | |
| } | |
| }); | |
| function unclickAll(clicked) { | |
| if (clicked.length > 0) { | |
| setTimeout(function() { | |
| var elem = clicked.pop(); | |
| $(elem).removeClass("blue"); | |
| unclickAll(clicked) | |
| }, 300); | |
| } else { | |
| // unclicked all, now removing listeners; | |
| bigSquares.off("click"); | |
| } | |
| } |
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
| <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.1.0/jquery.min.js"></script> |
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
| .square { | |
| border: 1px solid black; | |
| background: white; | |
| width: 50px; | |
| height: 50px; | |
| display: inline-block; | |
| margin: 15px 25px; | |
| &.tightened-up { | |
| margin-top: 0px; | |
| } | |
| &.tightened-down { | |
| margin-bottom: 0px; | |
| } | |
| &.small { | |
| width: 20px; | |
| height: 20px; | |
| margin-left: -25px - 20px/2; | |
| margin-bottom: 50px-20px; | |
| background: #57D497; | |
| } | |
| &.blue { | |
| background:#33C6E4; | |
| } | |
| } | |
| .invisible { | |
| border-color: transparent; | |
| } | |
| body { | |
| font-size: 0px; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment