Skip to content

Commit

Permalink
v0.2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
niklasramo committed Sep 28, 2016
1 parent 3e32179 commit 78e940c
Show file tree
Hide file tree
Showing 29 changed files with 207 additions and 45,233 deletions.
4 changes: 3 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,6 @@ language: node_js
node_js:
- "4"
env:
email: false
global:
- secure: VUU14zf9WKf/lRHKJInITvdvgppXDgrM0UYSxe3EvO5ElQKCivB/lHddIIUA8mdwQz5i5GCizrePssLr1OR0dfF98s33pYIuN4Enrpkyq7X90pKr7ru3ZrwrqLH2PC5U6ta4GppVsrgFYmRHpuwhGlm0Fpf0obGweTGXwsZtCBQ=
- secure: lsrw8vXXY6eOHxEGh3oB57zEtUlw1tt0CnJ8PLRGb2twumDpzKeeAKXSJjvbb13csGZvJbesOgpufdXtFIoT9LraGLA14xBBS7xVTPuhr0NCEC/MEpsXVvNkS10Vd+VsEtNMvPpMe4a0vRkNge+IlhQY4pRpnME14kaniF9BiCE=
3 changes: 3 additions & 0 deletions AUTHORS.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Authors ordered by first contribution.

Niklas Rämö <[email protected]>
Binary file removed demo/fonts/glyphicons-halflings-regular.eot
Binary file not shown.
288 changes: 0 additions & 288 deletions demo/fonts/glyphicons-halflings-regular.svg

This file was deleted.

Binary file removed demo/fonts/glyphicons-halflings-regular.ttf
Binary file not shown.
Binary file removed demo/fonts/glyphicons-halflings-regular.woff
Binary file not shown.
Binary file removed demo/fonts/glyphicons-halflings-regular.woff2
Binary file not shown.
10 changes: 2 additions & 8 deletions demo/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,17 @@
<head>
<meta charset="utf-8">
<meta http-equiv="x-ua-compatible" content="ie=edge">
<title>Muuri - A dynamic grid layout with built-in support for dragging and dropping grid items.</title>
<title>Muuri</title>
<meta name="viewport" content="user-scalable=no, width=device-width, initial-scale=1, maximum-scale=1">
<link rel="stylesheet" href="styles/normalize.css">
<link rel="stylesheet" href="styles/main.css">
<link href='https://fonts.googleapis.com/css?family=Fira+Sans:400,300,300italic,400italic,500,500italic,700,700italic' rel='stylesheet' type='text/css'>
<script src="scripts/vendor/palikka.js"></script>
</head>

<body>

<section id="demo">
<div class="container">

<div class="btn-group" role="group" aria-label="...">
<div class="btn-group">
<button type="button" class="btn btn-default demo-init">Init</button>
<button type="button" class="btn btn-default demo-destroy">Destroy</button>
<button type="button" class="btn btn-default demo-show">Show</button>
Expand All @@ -35,9 +32,6 @@
</section>

<script src="scripts/vendor/jquery.js"></script>
<script src="scripts/vendor/bootstrap.js"></script>
<script src="scripts/vendor/lodash.js"></script>
<script src="scripts/vendor/mezr.js"></script>
<script src="scripts/vendor/velocity.js"></script>
<script src="scripts/vendor/hammer.js"></script>
<script src="../muuri.js"></script>
Expand Down
96 changes: 38 additions & 58 deletions demo/scripts/main.js
Original file line number Diff line number Diff line change
@@ -1,43 +1,24 @@
palikka
.define(['jQuery'], function () {

return window[this.id];

})
.define('docReady', ['jQuery'], function ($) {

return palikka.defer(function (resolve) {
$(resolve);
});

})
.define('demo', ['jQuery', 'docReady'], function ($) {
$(function () {

var m = {};
var $grid = $('.grid');
var $root = $('html');
var uuid = 0;

m.grid = null;

m.init = function () {

init();

// Bind events.
$('.demo-init').on('click', init);
$('.demo-destroy').on('click', destroy);
$('.demo-show').on('click', show);
$('.demo-hide').on('click', hide);
$('.demo-add').on('click', add);
$('.demo-remove').on('click', remove);
$('.demo-refresh').on('click', refresh);
$('.demo-layout').on('click', layout);
$('.demo-synchronize').on('click', synchronize);

return m;

};
var grid = null;

// Bind events.
$('.demo-init').on('click', init);
$('.demo-destroy').on('click', destroy);
$('.demo-show').on('click', show);
$('.demo-hide').on('click', hide);
$('.demo-add').on('click', add);
$('.demo-remove').on('click', remove);
$('.demo-refresh').on('click', refresh);
$('.demo-layout').on('click', layout);
$('.demo-synchronize').on('click', synchronize);

// Init.
init();

//
// Helper utilities
Expand Down Expand Up @@ -73,18 +54,19 @@ palikka

function init() {

if (!m.grid) {
if (!grid) {

var dragCounter = 0;

m.grid = new Muuri({
grid = new Muuri({
container: $grid.get(0),
items: generateElements(20),
dragEnabled: true,
dragReleaseEasing: 'ease-in',
dragContainer: document.body
});

m.grid
grid
.on('dragstart', function () {
++dragCounter;
$root.addClass('dragging');
Expand All @@ -101,19 +83,19 @@ palikka

function destroy() {

if (m.grid) {
m.grid.destroy();
if (grid) {
grid.destroy();
$grid.empty();
m.grid = null;
grid = null;
uuid = 0;
}

}

function show() {

if (m.grid) {
m.grid.show(_.sampleSize(m.grid.get('inactive'), 5), function (items) {
if (grid) {
grid.show(grid.get('inactive').slice(0, 5), function (items) {
console.log('CALLBACK: Hide ' + items.length + ' items');
});
}
Expand All @@ -122,8 +104,8 @@ palikka

function hide() {

if (m.grid) {
m.grid.hide(_.sampleSize(m.grid.get('active'), 5), function (items) {
if (grid) {
grid.hide(grid.get('active').slice(0, 5), function (items) {
console.log('CALLBACK: Hide ' + items.length + ' items');
});
}
Expand All @@ -132,12 +114,12 @@ palikka

function add() {

if (m.grid) {
if (grid) {
var items = generateElements(5);
items.forEach(function (item) {
item.style.display = 'none';
});
m.grid.show(m.grid.add(items), function (items) {
grid.show(grid.add(items), function (items) {
console.log('CALLBACK: Added ' + items.length + ' items');
});
}
Expand All @@ -146,9 +128,9 @@ palikka

function remove() {

if (m.grid) {
m.grid.hide(_.sampleSize(m.grid.get('active'), 5), function (items) {
m.grid.remove(items, true);
if (grid) {
grid.hide(grid.get('active').slice(0, 5), function (items) {
grid.remove(items, true);
console.log('CALLBACK: Removed ' + items.length + ' items');
});
}
Expand All @@ -157,8 +139,8 @@ palikka

function layout() {

if (m.grid) {
m.grid.layout(function () {
if (grid) {
grid.layout(function () {
console.log('CALLBACK: Layout');
});
}
Expand All @@ -167,20 +149,18 @@ palikka

function refresh() {

if (m.grid) {
m.grid.refresh();
if (grid) {
grid.refresh();
}

}

function synchronize() {

if (m.grid) {
m.grid.synchronize();
if (grid) {
grid.synchronize();
}

}

return m.init();

});
Loading

0 comments on commit 78e940c

Please sign in to comment.