Advertisement
Boquete

Untitled

Jun 6th, 2017
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. (function() {
  2.     function getClass(name) {
  3.         return document.getElementsByClassName(name)[0];
  4.     }
  5.  
  6.     /**
  7.      * We are overriding css viewport height value because it's
  8.      * taller than the visible part of the document in some
  9.      * mobile browser. Read more: https://goo.gl/CyugDO
  10.      */
  11.     function divsHeights() {
  12.         const clientHeight = document.documentElement.clientHeight;
  13.         getClass('wrapper').style.height = (clientHeight + 'px');
  14.         getClass('projects__hidden').style.height = getClass('projects').height + 'px';
  15.         getClass('scroll').style.marginTop = ('calc(' + clientHeight + 'px - 4em)');
  16.     }
  17.  
  18.     /**
  19.      * This function decreases scroll alert box opacity,
  20.      * taking content scroll position and dividing by some scale
  21.      */
  22.     function scrollOpacity() {
  23.         getClass('content').onscroll = function() {
  24.             const scrollText = (getClass('scroll'));
  25.             const scrollIcons = (getClass('about__scroll'));
  26.             const range = (1 - ((getClass('content').scrollTop) / 200));
  27.             scrollText.style.opacity = range;
  28.             scrollIcons.style.opacity = range;
  29.         };
  30.     }
  31.    
  32.     function projectsState() {
  33.         const projects = document.querySelectorAll('.piotrantosz, .cyfrowa, .lingsense, .megatruck, .taxi, .sugarizer');
  34.         const projectsHidden = getClass('projects__hidden');
  35.         const projectsCards = getClass('projects__cards');
  36.         const close = getClass('close');
  37.  
  38.         projects.forEach(function(entry) {
  39.             const hiddenClassDescription = getClass(entry.getAttribute('class') + '__description');
  40.             entry.addEventListener('click', function() {
  41.                 projectsHidden.style.opacity = 1;
  42.                 projectsHidden.style.visibility = 'visible';
  43.                 hiddenClassDescription.style.display = 'block';
  44.                 projectsCards.style.opacity = 0;
  45.                 document.querySelectorAll('.title, .close').forEach(
  46.                     function(entry) {
  47.                         entry.addEventListener('click', function() {
  48.                             hiddenClassDescription.style.display = 'none';
  49.                             projectsHidden.style.opacity = 0;
  50.                             projectsHidden.style.visibility = 'hidden';
  51.                             projectsCards.style.opacity = 1
  52.                         }, false);
  53.                     }
  54.                 );
  55.             }, false);
  56.         });
  57.     }
  58.  
  59.     divsHeights();
  60.     scrollOpacity();
  61.     projectsState();
  62. })();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement