artbox-lazy.js
1.27 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
$(function() {
lazyInit();
$(document).on('pjax:complete', function() {
lazyInit();
});
$(document).on('translated.owl.carousel', function() {
lazyInit();
});
});
function lazyInit() {
$('img.artbox-lazy').lazyload({
skip_invisible: true
});
lazyThreshold();
lazyEvent();
lazyEffect();
}
function lazyThreshold() {
$.each($('img.artbox-lazy-threshold'), function(index, value) {
var threshold = 205;
var attribute = $(value).data('threshold');
if(attribute) {
threshold = attribute;
}
$(value).lazyload({
threshold: threshold
});
});
}
function lazyEvent() {
$.each($('img.artbox-lazy-event'), function(index, value) {
var event = 'lazy.artbox';
var attribute = $(value).data('event');
if(attribute) {
event = attribute;
}
$(value).lazyload({
event: event
});
});
}
function lazyEffect() {
$.each($('img.artbox-lazy-effect'), function(index, value) {
var effect = 'fadeIn';
var attribute = $(value).data('effect');
if(attribute) {
effect = attribute;
}
$(value).lazyload({
effect: effect
});
});
}