const SCROLL_MARGIN = 200; let isPhone = false if( /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent) ) { isPhone = true; } if (!isPhone) { $(window).scroll(() => { let scrollPos = $(document).scrollTop() let winHeight = $(window).height() $('.scroll').each((i, e) => { let offset = $(e).offset().top let eleHeight = $(e).height() if ($(e).hasClass('change') && $(e).hasClass('scroll')) { let start = offset - winHeight + eleHeight let stop = offset - eleHeight if (scrollPos <= start) { $(e).find('.below').css('opacity', 0) } else if (scrollPos >= stop) { $(e).find('.below').css('opacity', 1) } else { let percent = (scrollPos - start) / (stop - start) $(e).find('.below').css('opacity', percent) } } else if ($(e).hasClass('text-appear')) { let start = offset - (winHeight / 2) let stop = offset let percent = (scrollPos - start) / (stop - start) let numBlocks = $(e).find('.info').length $(e).find('.info').each((i, block) => { let order = parseInt($(block).attr('order')) let subPercent = (numBlocks * percent ) - (order / 2) if (subPercent <= 0) { $(block).css('opacity', 0) } else if (subPercent >= 1) { $(block).css('opacity', 1) } else { $(block).css('opacity', subPercent) } }) let one = 4 * percent let two = (4 * percent) - 1 } else if ($(e).hasClass('scroll--fade')) { let start = offset - winHeight let stop = start + (eleHeight * 4) let percent = (scrollPos - start) / (stop - start) let margin = eleHeight * percent / 2 if (percent <= 0) { $(e).css({ opacity: 0, marginTop: '0px' }) } else if (percent >= 1) { $(e).css({ opacity: 1, marginTop: eleHeight / 2 + 'px' }) } else { $(e).css({ opacity: percent, marginTop: margin }) } } else if ($(e).hasClass('scroll--numbersloop')) { let start = offset - winHeight if (scrollPos > start && $(e).attr('ran') != 'true') { $(e).attr('ran', 'true') randomNumbers($(e).html(), 20, e) } } else if ($(e).hasClass('sec__scroll-vertical')) { let relPos = (scrollPos - offset / 2) $(e).find('.scroll--vertical').each((i, block) => { let speed = 0.6 if ($(block).hasClass('scroll--vertical--slow')) speed = 0.3 if ($(block).hasClass('scroll--vertical--fast')) speed = 0.7 if ($(block).hasClass('scroll--vertical--stop')) speed = 0 if ($(block).hasClass('scroll--vertical--left')) { $(block).css('margin-left', (relPos * -speed) + 'px') } else if (!$(block).hasClass('scroll--vertical--stop')){ $(block).css('margin-left', (relPos * speed)- ($(window).width() * 4) + 'px') } }) } }) }) } function randomNumbers(end, reps, e) { let numbersList = [] while (numbersList.length != end.length) { numbersList = [] for (var i = 0; i < end.length; i++) { let num = Math.round(Math.random() * 10) if (num < 10) { numbersList.push(num) } } } if (end.indexOf(',') != -1) { numbersList[end.indexOf(',')] = ',' } if (end.indexOf('.') != -1) { numbersList[end.indexOf('.')] = '.' } if (end.indexOf('%') != -1) { numbersList[end.indexOf('%')] = '%' } if (end.indexOf('x') != -1) { numbersList[end.indexOf('x')] = 'x' } let string = numbersList.join('') $(e).html(string) setTimeout(() => { reps-- if (reps > 0) { randomNumbers(end, reps, e) } else { $(e).html(end) } }, 50) } $(document).ready(function(){ $('.closeStrip').on('click',function(){ $(this).closest('.stripLinkBox').fadeOut() }) });