treehouse : what would you like to learn today?
Web Design Web Development iOS Development

Chris' Latest Article. (start and stop slider)

  • hey all, I am just trying to do chris' tutorial , I've written all the javascript, although I'm quite a dummy when it comes to javascript so i've messed somthing up and its not working, so I was wondering if someone could take a look at my javascript code and let me know if and what i've done wrong.

    thanks in advance
    Michael.


    var delayLength: 40000;
    var panelWidth = 960;
    var numPanels = 3;
    var tooFar = -(panelWidth * numPanels);

    $(function(){

    $(\"#slider\").append('<a href=\"#\" id=\"slider-stopper\">Stop</a>');
    function doMove() {

    var leftValue = $(\"#mover\").css(\"left\");
    var movement = parseFloat(leftValue, 10) - panelWidth;

    if (movement == toofar) {

    $(\".slide img\").animate({
    \"top\": -200
    }, function() {
    $(\"#mover\").animate){
    \"left\": 0
    }, function() {
    $(\".slide img\").animate({
    \"top\": 20
    });
    });
    })

    }
    else {
    $(\".slide img\").animate({
    \"top\": -200
    }, function() {
    $(\"#mover\").animate({
    \"left\": movement
    }, function(){
    $(\".slide img\").animate({
    \"top\": 20
    });
    });
    });
    };

    }

    });