Grow your CSS skills. Land your dream job.

Opening animation properties on external file with function (jQuery)

  • # May 17, 2013 at 12:19 am

    i have a function like ths

    $(“.nav_button”).click(function() {
    $(“.slides”).animate({ animation properties here });
    });

    What i want todo is store the animation properties in a separate jquery file and call that file with that function. And the animation occurs according to the properties in the external file. And how would the properties in the external file be written?

    # May 17, 2013 at 12:44 am

    Something like this:

    var animationOptions = {
    duration : 400,
    easing : ‘swing’
    }

    $(‘.slides’).animate({
    height: 10
    }, animationOptions);

    # May 17, 2013 at 5:34 am

    External file could be JSON and call it with GET.

    $.getJSON(‘/path/to/file.json’, function(data) {
    console.log(data); // verify it works
    });

    # May 17, 2013 at 7:16 am

    @CrocoDillon but how would the animation properties be written in the JSON file? This is the animation i have

    $(“.slides”).animate({left:’100%’});

    How would that be written in the JSON file?

    # May 17, 2013 at 3:41 pm

    I’m guessing `{left:’100%’}`, in a file named .json could work.

Viewing 5 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic.

*May or may not contain any actual "CSS" or "Tricks".