-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfunctions.js
More file actions
81 lines (69 loc) · 1.92 KB
/
functions.js
File metadata and controls
81 lines (69 loc) · 1.92 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
(function($,sr){
var debounce = function(func, threshold, execAsap) {
var timeout;
return function debounced () {
var obj = this, args = arguments;
function delayed () {
if (!execAsap)
func.apply(obj, args);
timeout = null;
}
if (timeout)
clearTimeout(timeout);
else if (execAsap)
func.apply(obj, args);
timeout = setTimeout(delayed, threshold || 50);
};
};
jQuery.fn[sr] = function(fn){ return fn ? this.bind('resize', debounce(fn)) : this.trigger(sr); };
})(jQuery,'smartresize');
(function ($) {
"use strict";
var $container = $('.list');
var colWidth = function () {
var w = $container.width(),
columnNum = 1,
columnWidth = 0;
if (w > 1200) {
columnNum = 5;
} else if (w > 900) {
columnNum = 4;
} else if (w > 600) {
columnNum = 3;
} else if (w > 300) {
columnNum = 1;
}
columnWidth = Math.floor(w/columnNum);
columnWidth = columnWidth - 10;
$container.find('.item').each(function() {
var $item = $(this);
var multiplier_w = $item.attr('class').match(/item-w(\d)/);
var width = multiplier_w ? columnWidth*multiplier_w[1]-4 : columnWidth-4;
$item.css({
width: width
});
});
return columnWidth;
};
var isotope = function () {
$container.isotope({
resizable: false,
itemSelector: '.item',
masonry: {
columnWidth: colWidth(),
gutter: 10
}
});
};
$('#filterNav').on('click', 'a', function () {
var selector = $(this).attr('data-filter');
$container.isotope({
filter: selector
});
});
isotope();
$(window).smartresize(isotope);
$(window).load(function () {
isotope();
});
})(jQuery);