tile.js
2.76 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
82
83
84
85
86
// tile
$(document).on('click', function(e) {
var $target = $(e.target);
if ($target.is('[data-toggle="tile"], [data-toggle="tile"] *') && !$target.is('[data-ignore="tile"], [data-ignore="tile"] *')) {
var $trigger = $target.closest('[data-toggle="tile"]');
if ($trigger.attr('data-parent') != null) {
$($trigger.attr('data-parent')).find('.tile-active-show').collapse('hide');
};
$(getTargetFromTrigger($trigger)).collapse('toggle');
} else if ($target.is('[data-dismiss="tile"]')) {
$target.closest('.tile-collapse').find('.tile-active-show').collapse('hide');
} else if (!$target.is('.tile-collapse, .tile-collapse *')) {
tReset();
};
});
function tReset() {
$('.tile-collapse.active').each(function(index) {
var $collapse = $('.tile-active-show', $(this));
if (!$collapse.hasClass('tile-active-show-still')) {
$collapse.collapse('hide');
};
});
}
// tile hide
$(document).on('hide.bs.collapse', '.tile-active-show', function() {
$(this).closest('.tile-collapse').css({
'-webkit-transition-delay': '',
'transition-delay': ''
}).removeClass('active');
});
// tile show
$(document).on('show.bs.collapse', '.tile-active-show', function() {
$(this).closest('.tile-collapse').css({
'-webkit-transition-delay': '',
'transition-delay': ''
}).addClass('active');
});
// tile wrap animation
$('.tile-wrap-animation').each(function(index) {
var tileAnimationDelay = 0,
tileAnimationTransform = 100;
$('> .tile', $(this)).each(function(index) {
$(this).css({
'-webkit-transform': 'translate(0, ' + tileAnimationTransform + '%)',
'-ms-transform': 'translate(0, ' + tileAnimationTransform + '%)',
'transform': 'translate(0, ' + tileAnimationTransform + '%)',
'-webkit-transition-delay': tileAnimationDelay + 's',
'transition-delay': tileAnimationDelay + 's'
});
tileAnimationDelay = tileAnimationDelay + 0.1;
tileAnimationTransform = tileAnimationTransform + 10;
});
});
$(window).on('DOMContentLoaded scroll', function() {
tileInView();
});
function tileInView() {
$('.tile-wrap-animation:not(.isinview)').each(function() {
var $this = $(this);
if (tileInViewCheck($this) && (!$this.hasClass('avoid-fout') || ($this.hasClass('avoid-fout') && $this.hasClass('avoid-fout-done'))) && (!$this.hasClass('el-loading') || ($this.hasClass('el-loading') && $this.hasClass('el-loading-done'))) && !$this.parents('.avoid-fout:not(.avoid-fout-done)').length && !$this.parents('.el-loading:not(.el-loading-done)').length) {
$this.addClass('isinview');
};
});
}
function tileInViewCheck(tile) {
tile = tile[0];
var rect = tile.getBoundingClientRect();
return (
rect.top <= window.innerHeight &&
rect.right >= 0 &&
rect.bottom >= 0 &&
rect.left <= window.innerWidth
);
}