public/themes/templates/1/includes/js/about.js   A
last analyzed

Complexity

Total Complexity 9
Complexity/F 1.13

Size

Lines of Code 26
Function Count 8

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 14
dl 0
loc 26
rs 10
c 0
b 0
f 0
wmc 9
mnd 1
bc 1
fnc 8
bpm 0.125
cpm 1.125
noi 0

2 Functions

Rating   Name   Duplication   Size   Complexity  
A about.js ➔ showBlocks 0 5 2
B about.js ➔ hideBlocks 0 5 7
1
jQuery(document).ready(function ($) {
2
    var timelineBlocks = $('.cd-timeline-block'),
3
        offset = 0.8;
4
5
    // hide timeline blocks which are outside the viewport
6
    hideBlocks(timelineBlocks, offset);
7
8
    // on scolling, show/animate timeline blocks when enter the viewport
9
    $(window).on('scroll', function () {
10
        (!window.requestAnimationFrame)
11
            ? setTimeout(function () { showBlocks(timelineBlocks, offset); }, 100)
12
            : window.requestAnimationFrame(function () { showBlocks(timelineBlocks, offset); });
13
    });
14
15
    function hideBlocks (blocks, offset) {
16
        blocks.each(function () {
17
            ($(this).offset().top > $(window).scrollTop() + $(window).height() * offset) && $(this).find('.cd-timeline-img, .cd-timeline-content').addClass('is-hidden');
18
        });
19
    }
20
21
    function showBlocks (blocks, offset) {
22
        blocks.each(function () {
23
            ($(this).offset().top <= $(window).scrollTop() + $(window).height() * offset && $(this).find('.cd-timeline-img').hasClass('is-hidden')) && $(this).find('.cd-timeline-img, .cd-timeline-content').removeClass('is-hidden').addClass('bounce-in');
24
        });
25
    }
26
});
27