Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

JavaScript

How can i make this animated?

HI,

I want to make a navbar so when i scroll down, my name slides in from left, how can i add this to this script?

                <script type="text/javascript">
    $('.menu').addClass('original').clone().insertAfter('.menu').addClass('cloned').css('position','fixed').css('top','0').css('margin-top','0').css('z-index','500').removeClass('original').hide();
$('.navbar-name').hide();
scrollIntervalID = setInterval(stickIt, 10);


function stickIt() {

var orgElementPos = $('.original').offset();
orgElementTop = orgElementPos.top;

if ($(window).scrollTop() >= (orgElementTop)) {
  // scrolled past the original position; now only show the cloned, sticky element.

  // Cloned element should always have same left position and width as original element.
  orgElement = $('.original');
  coordsOrgElement = orgElement.offset();
  leftOrgElement = coordsOrgElement.left;
  widthOrgElement = orgElement.css('width');
  $('.cloned').css('left',leftOrgElement+'px').css('top',0).css('width',widthOrgElement).show();
  $('.navbar-name').show();
  $('.original').css('visibility','hidden');
} else {
  // not scrolled past the menu; only show the original menu.
  $('.cloned').hide();
  $('.original').css('visibility','visible');
  $('.navbar-name').hide();
}
}
    </script>

can you provide your html?

Oh right, though that would be enoguh xd

    <!-- Header -->
    <header id="masthead" style="background-image: url('assets/img/13.jpg')">
        <div class="image-overflow">
            <div class="header-background-image">

            </div><!-- /header-background-image -->
        </div><!-- /image-overflow -->

        <div class="row top-banner">
            <div class="container">
                <a class="myName" href="" title="My Name" rel="home"><h1>My Name</h1></a>
            </div><!-- /container -->
        </div><!-- /top-banner -->

        <div class="menu">
            <nav class="navbar navbar-default">
                <div class="container">
                    <div class="container-fluid">

                        <!-- Brand and Mobile Version -->
                        <div class="navbar-header">
                            <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#main-navbar" aria-expanded="false">
                            <span class="sr-only">Toggle navigation</span>
                            <span class="icon-bar"></span>
                            <span class="icon-bar"></span>
                            <span class="icon-bar"></span>
                            </button>


                          </div><!-- /navbar-header -->

                        <!-- Navbar Links -->
                            <div class="collapse navbar-collapse" id="main-navbar">
                                <a class="navbar-name" href="#">Aurelian Spodarec</a>

                                <ul class="nav navbar-nav">
                                    <li><a href="home.php">Home</a></li>
                                    <li><a href="about.php">About Name</a></li>
                                    <li><a href="blog.php">Blog</a></li>
                                    <li><a href="blog.php">Resources</a></li>
                                    <li><a href="contact.php">Get in Touch</a></li>
                                </ul><!-- /nav navbar-nav -->

                                <div class="search pull-right">
                                    <span class="glyphicon glyphicon-search"></span>
                                </div><!-- /search -->
                            </div><!-- main-navbar -->
                    </div><!-- /container-fluid -->
                </div><!-- /container -->
            </nav><!-- /navbar navbar-default -->
        </div>
    </header>