Mondrian
How do I make an mondrian?
Hit spacebar or shake your phone to create a new composition, and drag blocks about to adjust.Made using Dave Desandro’s Packery and Draggibilly.. What is a mondrian? How do you make a mondrian? This script and codes were developed by Chrisarmstrong on 24 November 2022, Thursday.
Mondrian - Script Codes HTML Codes
<!DOCTYPE html>
<html >
<head> <meta charset="UTF-8"> <title>Mondrian</title> <script src="https://s.codepen.io/assets/libs/modernizr.js" type="text/javascript"></script>
<meta name="viewport" content="width=device-width">
<meta name="apple-mobile-web-app-capable" content="yes"> <link rel="stylesheet" href="css/style.css">
</head>
<body> <div id="container">
</div> <script src='http://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js'></script>
<script src='https://packery.metafizzy.co/packery.pkgd.min.js'></script>
<script src='https://draggabilly.desandro.com/draggabilly.pkgd.min.js'></script>
<script src='https://raw.githubusercontent.com/alexgibson/shake.js/master/shake.js'></script> <script src="js/index.js"></script>
</body>
</html>
Mondrian - Script Codes CSS Codes
.item { width:48px; height:48px; background:white; display:block; cursor:move;
}
.item:hover { border:4px solid rgba(0,0,0,0.2); box-sizing:border-box;
}
#codepen-footer { display:none;
}
.item:nth-child(3){ background:#E50F05;
}
.item:nth-child(7){ background:#264D98;
}
.item:nth-child(9){ background:#F9DE45;
}
.w2 { width:116px;
}
.h2 { height:116px;
}
.h3 { height:184px;
}
.w3 { width:184px;
}
html { width:100%; height:100%; display:table;
}
body { width:100%; height:100%; background:black; margin:0; padding:0; vertical-align:middle; display:table-cell;
}
#container { width:320px; min-height:568px; max-height:100vh; overflow:hidden; outline:1px solid white; margin:auto;
}
Mondrian - Script Codes JS Codes
// init
setStage();
function setStage() { var $container = $('#container'); $container.packery( 'remove', $('.item') ); $container.packery({ itemSelector: '.item', gutter:20, columnWidth: 48, rowHeight: 48 }); var i=34; $('#container').html(''); for (i; i > -1; i--) { var item = document.createElement("div"); switch (Math.round(Math.random()*10)) { case 1: item.className="item w2"; i = i-1; break; case 2: item.className="item h2"; i = i-1; break; case 3: item.className="item h2 w2"; i = i-3; break; case 4: item.className="item h3"; i = i-2; break; case 5: item.className="item w3"; i = i-2; break; case 6: item.className="item w3 h3"; i = i-8; break; default: item.className="item"; } $('#container').append(item); $container.packery( 'appended', item ); if (i<=0) { $container.find('.item').each( function( i, itemElem ) { // make element draggable with Draggabilly var draggie = new Draggabilly( itemElem ); // bind Draggabilly events to Packery $container.packery( 'bindDraggabillyEvents', draggie ); }); } }
}
function layout() { $container.find('.item').each( function( i, itemElem ) { // make element draggable with Draggabilly var draggie = new Draggabilly( itemElem ); // bind Draggabilly events to Packery $container.packery( 'bindDraggabillyEvents', draggie ); });
}
window.addEventListener('shake', shakeEventDidOccur, false);
//function to call when shake occurs
function shakeEventDidOccur () { //put your own code here etc. onShake();
}
$('body').keyup(function(e){ if(e.keyCode == 32){ // user has pressed space onShake(); }
});
function onShake() { setStage();
}
Developer | Chrisarmstrong |
Username | chrisarmstrong |
Uploaded | November 24, 2022 |
Rating | 4 |
Size | 2,787 Kb |
Views | 26,312 |
Find the perfect freelance services for your business! Fiverr's mission is to change how the world works together. Fiverr connects businesses with freelancers offering digital services in 500+ categories. Find Developer!
Name | Size |
Herdbook | 3,615 Kb |
Colour slider | 4,589 Kb |
Quizmaster | 5,888 Kb |
Fibonacci | 4,033 Kb |
Platoon | 2,164 Kb |
Juxtapose | 2,395 Kb |
A Pen by chrisarmstrong | 1,651 Kb |
A Pointless Experiment | 2,343 Kb |
Mondrian 2 | 2,241 Kb |
WW1 Loader | 2,242 Kb |
Jasper is the AI Content Generator that helps you and your team break through creative blocks to create amazing, original content 10X faster. Discover all the ways the Jasper AI Content Platform can help streamline your creative workflows. Start For Free!
Name | Username | Size |
Sencha Touch 2.3.1 Basic Grid Example | Trozdol | 2,770 Kb |
Form Labels | Bartuc | 2,717 Kb |
Portfolio Landing Page | FDfranklin | 3,585 Kb |
Web Spiral - p5.js | TWAIN | 2,183 Kb |
Simple jQuery Slider | Jurbank | 2,874 Kb |
NT Tribute | Skybutterfly | 2,850 Kb |
Sticky div | Kaslab | 2,225 Kb |
Placeholder support for contentEditable elements, without JavaScript | Flesler | 1,863 Kb |
Fluid Responsive Typography | Jonmilner | 4,205 Kb |
Fullscreen audio play button | 72 | 2,148 Kb |
Surf anonymously, prevent hackers from acquiring your IP address, send anonymous email, and encrypt your Internet connection. High speed, ultra secure, and easy to use. Instant setup. Hide Your IP Now!