Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using it's URL and the proper URL extention.

+ add another resource

JavaScript

Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <header class="banner">
  <img src="https://res.cloudinary.com/djhkdplck/image/upload/v1523891956/lavender-ribbon.png" alt="lavender-ribbon">
  <h1>Tribute to Terry Fox</h1>
</header>
<div class="main-wrap">

  <section class="hero">
    <picture>
      <div class="hero--paused">PAUSED</div>
      <div class="hero--end">END</div>
    </picture>
  </section>

  <section class="tribute font-style-1">
    <p class="tribute-line1"></p>
    <p class="tribute-line2"></p>
    <p class="tribute-line3"></p>
    <div class="tribute-control-btn-wrap">
      <button class="tribute-control-btn--fwd"><i class="fa fa-forward
        "></i></button>
      <button class="tribute-control-btn--toggle-play"><i class="fa fa-pause"></i></button>
      <button class="tribute-control-btn--fbwd"><i class="fa fa-fast-backward"></i></button>
    </div>
    <div class="tribute-overlay">
      <div class="tribute-info-icon font-style-1"><i class="fa fa-info-circle"></i></div>
      <div class="tribute-info-wrap">Did you know? <span>Lavender</span> is the ribbon color used for awareness of all cancer types.</div>
      <button class="tribute-info-wiki"><a href="https://en.wikipedia.org/wiki/Terry_Fox"><i class="fa fa-wikipedia-w"></i></a></button>
    </div>
  </section>

</div>
              
            
!

CSS

              
                * { 
  box-sizing: border-box;
}

body {
  font-family: 'Quattrocento', serif;
 	color:#333333;
  background-color: #fff;
  width: 100%;
  min-height:100%;
  height: 100%;
  overflow-x:hidden;
  margin: 0;
}
.banner {
  height: 8vh;
}
.banner img {
  position: relative;
  display:inline-block;
  top: 10px;
  height: 56px;
}

.banner h1 { 
  display: inline-block;
  font-family: 'Pacifico', cursive;
  letter-spacing: 2px;
  color: #4a4a4b;
  margin: 0 1% 0;  
}

.font-style-1 {
  font-size: 1.5em;
  line-height: 1.5em;  
}

.fa {
  font-size: 1.5em;
}

.main-wrap {
  min-height:89vh;
  margin: 1%;
  background-color: #CACADC;
  box-shadow: 2px 2px 4px #000000;
}

.hero {
  padding: 1%;
}
.hero picture {
  position: relative;
  display: block;
  width: 100%;
  min-height:70vh;
  background-color: #e0deeb;
  background-image: url("https://res.cloudinary.com/djhkdplck/image/upload/v1523659021/terrysface-zoomed.jpg");
  background-size: contain;
  background-position:center;
  background-repeat: no-repeat;
  box-shadow: 4px 4px 8px #000000;
  transition: 1.0s;
}

.hero .hero--end{ display:none; }
.hero .hero--paused { display:none; }

.hero .hero--end,
.hero .hero--paused {
  background: rgba( 255,255,255, 0.5);
  position: absolute;
  bottom:0;
  right:10px;
  font-size: 1.5em;
  color: #4a4a4b;
}

.tribute {
  position: relative;
  margin-top: 1%;  
  padding-bottom: 1%;
}

.tribute-line1,
.tribute-line2,
.tribute-line3{
  width: 90%;
  min-height:1.5em;
  margin: 0 auto;
  text-align: center;
  opacity:0;
}
.tribute-control-btn-wrap {
  position: absolute;
  top: 0;
  right: 1.5%;
}
.tribute-control-btn--fbwd,
.tribute-control-btn--toggle-play,
.tribute-control-btn--fwd {
  position:relative;
  display:block;
  height: 30px;
  float: right;
  box-shadow: 2px 2px 2px #000000;
}

.tribute-overlay {
  position:absolute;
  top: -9%;
  left: 10px;
  height: 100%;
  width: 49%;
  z-index: 2;
}
.tribute-overlay:hover {
  position:absolute;
  left:10px;
  width: 98%;
  height: 100%;
  background-color: #b8b8c8;
  transition: background-color .3s;
  z-index: 2;
}

.tribute-overlay:hover .tribute-info-icon {
 opacity:0.5;
 z-index: 2;
}

.tribute-overlay:hover .tribute-info-wrap {
  position: relative;
  color: #000;
  margin-top: 1%;
  text-align: center;
  opacity: 1;
  z-index: 2;
} 

.tribute-overlay:hover .tribute-info-wiki {
  position: absolute;
  left: 50%;
  top: 75%;
  transform: translate(-50%, -50%);
  opacity: 1;
} 

.tribute-info-icon {
  font-size: 0.833em;
  position: absolute;
  top: 6%;
  left:10px;
  color:#2e2e32;
}

.tribute-info-wrap,
.tribute-info-wiki {
  opacity:0;
  margin: auto;
}

.tribute-info-wrap span {
  color: #6e6599;
}

/* 
** MEDIA QUERIES
*/ 
@media only screen and (max-width: 600px) {

.banner {
  height: 7vh;
}

.banner img {
  top: 7px;
  height: 30px;
}  

.banner h1 { 
  font-size: 1.5em;
}

.main-wrap {
  min-height:91vh;
}

.font-style-1 {
  font-size: 1.25em;
  line-height: 1.25em;  
}

.fa {
  font-size: 1.25em;
}
.hero picture {
  min-height:40vh;
}
.tribute {
  position: relative;
  margin-top: 14%;  
  padding-bottom: 1%;
}

.tribute-line1,
.tribute-line2,
.tribute-line3{
  width: 90%;
  margin: 0 auto;
  padding: .5em 0em;
  text-align: center;
  opacity:0;
}

.tribute-control-btn-wrap {
  position: absolute;
  top: -6vh;
  right: 1.5%;
}

.tribute-overlay {
  margin-top: 1vh;
  top: -5%;
  left: 4px;
}

.tribute-overlay:hover {
  position:absolute;
  height:35vh;
  left:4px;
}

.tribute-info-icon {
  position: absolute;
  top: -4vh;
  left:2px;
}

.tribute-info-wrap {
  padding-top: 6vh;
}

}/* End media: max-width: 600px  
              
            
!

JS

              
                $(window).on( 'load', function() {
    
  /*
  ** Image Rotator
  */

  var bgImageArray = [
        "v1523659021/terrysface-zoomed.jpg",
        "v1523658991/terry-early-years.jpg", 
        "v1523659083/ny-marathon.jpg", 
        "v1525192519/training.jpg", 
        "v1523659005/terry-front-run.jpg", 
        "v1523659015/terry-on-stretcher.jpg", 
        "v1523658954/miles-to-go.jpg"
      ];
      
  // caches images, avoiding white flash between background replacements     
  var base ="https://res.cloudinary.com/djhkdplck/image/upload/";

  bgImageArray.forEach( function(img){
      new Image().src = base + img; 

  });

  var bgImg = {
    index: 0,
    
    fbwd: function () {
      this.index = 0;
      this.setBGImage();
    },
    
    fwd: function () {
      this.next();
    },
    
    next: function () {
      this.index++;
      this.setBGImage();
    },
    
    setBGImage: function () {
      $('.hero picture').css( 'background-image', "url(" + base + bgImageArray[this.index] + ")" );
    }
  };
    
  var tribStory = [
    [
      "Terry Fox - an activist in cancer research, ",
      "a hero to people worldwide.",
      "",
      "An athlete, ",
      "a humanitarian.",
      "",

      "Terry Fox - Canada's Marathon Man,",
      "his legacy lives on today.",
      ""
    ],
    [
      "Terry was a track and field champion in high school.",
      "He played first-string Varsity basketball,",
      "and was captain to his school's soccer team.",
      "In his senior year, it was discovered",
      "Terry had a very dangerous form of cancer.",
      "",
      "To keep the cancer from spreading, ",
      "his entire right leg would have to be amputated.",
      ""
    ],
    [    
      "The night before his surgery, ",
      "He read an article about Dick Traum, a NY runner.",
      "Dick was the first amputee to complete the NY marathon.",
      "Terry never forgot the article.",
      "He dreamed running across Canada.",
      "",
      "After the surgery, there was 16 months of follow-up treatment.",
      "At the clinic, he saw the other cancer patients.",
      "He saw their suffering. He listened to their cries."
    ],
    [
      "He could not forget what he had seen.",
      "He felt he was one of the lucky patients who survived.",
      "",
      "Terry wanted to raise money for Cancer Research",
      "and he was determined to take action to make it happen.",
      "He felt a responsibility. He wanted the hurting to stop.",
      "He had a special prosthetic made so he could run",    
      "and trained every day for 15 months, except for one.",
      "His mom forced him to take Christmas day off."
    ],
    [
      "On April 12, 1980, the Marathon of Hope began.",
      "Terry dipped his right leg into the Atlantic Ocean.",
      "He would run, a marathon a day, everyday.",
      "His goal - to receive a $1 donation from every Canadian.",
      "A testament to his will. Terry endured it all...",
      "Bad weather, the mental solitude, the physical pain.",
      "Terry ran 143 days, 3339 miles before he was forced to end his run",
      "At a tearful press conference, Terry sobbed the cancer has spread to his lungs",
      "He needed treatment, but if he could come back and finish, he would."
    ],
    [
      "$2 million dollars was raised before Terry had to stop running.",
      "Just days later, an impromptu telethon was organized in Terry Fox's name",
      "From his hospital bed, he watched the broadcast televised across Canada",
      "The Telethon raised $10 million dollars,",
      "and more importantly, the fund soon reached $24 million dollars,",
      "Terry's goal of getting $1 dollar from every Canadian was fulfilled",
      "Terry Fox single-handedly doubled the annual cancer research budget",
      "He became the youngest ever recipient of the Order of Canada",
      "Sadly, Terry succumbed to his cancer, dieing at age 22."
    ],
    [
      "As a Canadian, living at that time, we were all deeply affected by his death.",
      "However, Terry left more for his country than he could possibly realize.",
      "",
      "He left behind his spirit and determination,",
      "and a dream, which became his legacy.",
      "",
      "Thank you Terry Fox for caring about us.",
      "and thank you for watching.",
      ""
    ]
  ]; // end array
  
  var $line1 = $(".tribute-line1");
  var $line2 = $(".tribute-line2");
  var $line3 = $(".tribute-line3");

  var maxStorySegments = tribStory.length -1;
  var storySegment = 0;

  var maxLines = tribStory[storySegment].length;
  var line = 0;
  
  var paused = false;
  var tl = new TimelineMax({ onComplete: animateStory });
  
  
   // mouseenter/mouseleave
  $('.tribute-overlay').on( "mouseenter", function() {
    controls.togglePlay();
  });
  
  $('.tribute-overlay').on( "mouseleave", function() {
    controls.togglePlay();
  });
  
  // pause/play toggle btn
  $('.tribute-control-btn--toggle-play').on( "click", function() {
    controls.togglePlay();
  });
 
  // fast backward btn
  $('.tribute-control-btn--fbwd').on( "click", function() {
    storySegment = 0;
    line = 0; 
    bgImg.fbwd();
    controls.fbwd();   

    clearTimeLine();
    tl = new TimelineMax({ onComplete: animateStory });
    animateStory();
  });  
  
    // fast forward btn
  $('.tribute-control-btn--fwd').on( "click", function() {
    line = 0;
    clearTimeLine();
    tl = new TimelineMax({ onComplete: animateStory });
    if ( storySegment < maxStorySegments ) {
      storySegment++;
      bgImg.fwd();
      controls.fwd();
    }
    animateStory();
  });  
  

  function animateStory() {
   
    if ( ! paused ) {
      if ( line < maxLines ) {

        var totalLetters = 0, mSecs=0.5;
        totalLetters += tribStory[storySegment][line].length;
        totalLetters += tribStory[storySegment][line +1].length;
        totalLetters += tribStory[storySegment][line +2].length;
        mSecs += ( totalLetters / 5 * 0.1 + 0.5 ); 
        
        $line1.text( tribStory[storySegment][line] );
        $line2.text( tribStory[storySegment][line + 1] );
        $line3.text( tribStory[storySegment][line + 2] );
        
        // Note: Timeline invokes animateStory() after completing call to tl.to()
        tl.staggerTo([$line1, $line2, $line3], mSecs, { opacity: 1 }, 0.5);
        tl.to([$line1, $line2, $line3], mSecs * 0.7, { opacity: 0 }, "+=1.0");
        line += 3;
      } else if ( storySegment < maxStorySegments ) {
        storySegment++;
        bgImg.next();
        line = 0;
        animateStory();
      } else {
        controls.end();
      } 
      
    } else {
      setTimeout ( function () {
        animateStory();
      }, 100 );
    }
  }
  animateStory();

/*
** Playback controls
*/  
  var controls = {
 
    end: function () {
        if ( $('.tribute-control-btn--toggle-play').find('.fa-pause').length !== 0 ) {
          $('.fa-pause').removeClass("fa-pause").addClass("fa-play");
          $('.hero--end').css('display', "block");
          tl.pause();
          paused = true;
        }     
    },   
    
    fbwd: function () {
        this.play();
    },
    
    fwd: function () {
        this.play();
    },
    
    pause: function() {    
        $('.fa-pause').removeClass("fa-pause").addClass("fa-play");
        $('.hero--paused').css('display', "block");
        tl.pause();
        paused = true;
    },
    
    play: function() {
        $('.fa-play').removeClass("fa-play").addClass("fa-pause");
        $('.hero--paused').css('display', "none");
        
        if ( $('.hero--end').css('display') === 'block' ) {
          $('.hero--end').css('display', "none");
            storySegment = 0;
            line = 0; 
            bgImg.fbwd();
        }
        tl.play();
        paused = false;
    },
    
    togglePlay: function() {
      
        // btn showing PAUSE indicates tribute currently playing 
        if ( $('.tribute-control-btn--toggle-play').find('.fa-pause').length !== 0 ) {
          this.pause();

        } // btn showing PLAY indicates tribute currently paused
        else if ( $('.tribute-control-btn--toggle-play').find('.fa-play').length !== 0 ) {
          this.play();
        }
      
    }
    
  }; // end obj controls 
  
  // helper functions
  function clearTimeLine() {
    tl.clear();    
    tl.eventCallback("onComplete", null);
  }
 
}); // end IIFE
              
            
!
999px

Console