//Reference & Credits for animating grid with CSS3 transitions : http://blog.stevensanderson.com/2013/03/15/animating-lists-with-css-3-transitions/
//rest of it: https://twitter.com/jeetaz
var initialHeight;
var initialWidth;
var nCols = 0;
var nRows = 0;
var nWidgetCounts = 10;
$(function () {
initialHeight = $(".container").height();
initialWidth = $(".container").width();
$(".items").sortable({
containment: "parent",
//scrollSensitivity: 100,
//placeholder: 'placeholder',
start: function (event, ui) {
// Temporarily move the dragged item to the end of the list so that it doesn't offset the items
// below it (jQuery UI adds a 'placeholder' element which creates the desired offset during dragging)
$(ui.item).appendTo(this).addClass("dragging");
},
stop: function (event, ui) {
// jQuery UI instantly moves the element to its final position, but we want it to transition there.
// So, first convert the final top/left position into a translate3d style override
var newTranslation = "translate3d(" + ui.position.left + "px, " + ui.position.top + "px, 0)";
$(ui.item).css("-webkit-transform", newTranslation)
.css("transform", newTranslation);
// ... then remove that override within a snapshot so that it transitions.
$(ui.item).snapshotStyles().removeClass("dragging").releaseSnapshot();
}
});
// Workaround for Webkit bug: force scroll height to be recomputed after the transition ends, not only when it starts
$(".items").on("webkitTransitionEnd", function () {
$(this).hide().offset();
$(this).show();
});
function createListStyles(rulePattern, rows, cols, width, height) {
$('#headstyle').remove();
var rules = [], index = 0;
for (var rowIndex = 0; rowIndex < rows; rowIndex++) {
for (var colIndex = 0;...
Please Whitelist JSFiddle in your content blocker.
Help keep JSFiddle free for always by one of two ways:
Whitelist JSFiddle in your content blocker (two clicks)
Go PRO and get access to additional PRO features →
Join the 4+ million users, and keep the JSFiddle dream alive.
Ad-free
All ads in the editor and listing pages are turned completely off.
Use pre-released features
You get to try and use features (like the Palette Color Generator) months before everyone else.
Fiddle collections
Sort and categorize your Fiddles into multiple collections.
Private collections and fiddles
You can make as many Private Fiddles, and Private Collections as you wish!
Console
Debug your Fiddle with a minimal built-in JavaScript console.