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

              
                <a class="bttns" target="1"><span>item 1</span></a>
<a class="bttns" target="2"><span>item 2</span></a>
<a class="bttns" target="3"><span>item 3</span></a>

<div id="main_left">
  <div id="work_main1" class="targetDiv">
    <section class="content"><span class="tick"></span>
      <h3 class="title">project 1</h3><span class="desc">LANDINGSPAGE<p>Development</p></span><a class="work-link" href="#">View project</a>
    </section>
  </div>
  <div id="work_main2" class="targetDiv">
    <section class="content"><span class="tick"></span>
      <h3 class="title">project 2</h3><span class="desc">WORDPRESS CMS<p>Design & Development</p></span><a class="work-link" href="#">View project</a>
    </section>
  </div>
  <div id="work_main3" class="targetDiv">
    <section class="content"><span class="tick"></span>
      <h3 class="title">project 3</h3><span class="desc">GOOGLE CARDBOARD<p>UX & Development</p></span><a class="work-link" href="#">View project</a>
    </section>
  </div>
</div>
              
            
!

CSS

              
                .content {
  display: flex;
  justify-content: center;
  flex-direction: column;
  height: 100%;
  width: 100%;
  float: left;
}

.bttns {
  cursor: pointer;
  height: 32px;
  display: flex;
  align-items: center;
  float: left;
  margin: 10px;
}

.bttns:hover {
  color: red;
}

.active{
  color: red;
}
              
            
!

JS

              
                console.clear();
var currentSection;
var currentAnimation;
var requestedAnimation;

$('.bttns').each(function(i, el) {
  var title = $('.content > h3.title');
  var desc = $('.content > span.desc');
  var workButton = $('.content > a.work-link');
  var workDiv = $('#work_main' + $(this).attr('target'));
  var tl = new TimelineLite({
    paused: true,
    onReverseComplete: playRequestedAnimation
  })
  TweenLite.set(".targetDiv", {
    display: "none"
  })
  tl.set(workDiv, {
      display: 'none'
    })
    .set(title, {
      autoAlpha: 0,
      y: 10
    })
    .set(desc, {
      autoAlpha: 0,
      y: 10
    })
    .set(workButton, {
      autoAlpha: 0,
      y: 10
    });

  tl.to(workDiv, 0.1, {
      display: 'block'
    })
    .to(title, 0.3, {
      ease: Power1.easeIn,
      autoAlpha: 1,
      y: 0
    })
    .to(desc, 0.4, {
      ease: Power1.easeIn,
      autoAlpha: 1,
      y: 0
    })
    .to(workButton, 0.4, {
      ease: Power1.easeIn,
      autoAlpha: 1,
      y: 0
    });
  this.animation = tl;
});

$('.bttns').on('click touchstart', function(e) {
  console.log("you clicked on ");
  console.log(e.currentTarget);
  console.log("the number you want is " + e.currentTarget.getAttribute("target"));

  requestedAnimation = this.animation;

  console.log("requested animation for", e.currentTarget.getAttribute("target"))

  var sectionNumber = e.currentTarget.getAttribute("target")
  $(this).removeClass("active").addClass("active");
  //hide the old one
  if (currentAnimation) {
    console.log("currentAnimation needs to be reversed")
    currentAnimation.reverse().eventCallback("onReverseComplete", function() {
      playRequestedAnimation(currentSection)
    })
  } else {
    playRequestedAnimation(currentSection)
  }
  //show the new one
  currentSection = $("#work_main" + sectionNumber);
  $('.bttns').removeClass("active");
  $(this).addClass("active");

});

function playRequestedAnimation() {
  console.log("ready to play requested animation")
  requestedAnimation.play();
  currentAnimation = requestedAnimation;
}
              
            
!
999px

Console