Give help. Get help.

  • # January 15, 2018 at 4:45 pm

    I am trying to create a function with fullpage.js that allows me to randomly move to another “article” when the video displayed inside the article is over.

    For that I have to use the function “$ .fn.fullpage.moveTo (X, Y);”

    X is the number of the section (the first one must begin with 1)
    Y is the article number (the first one must start with 0)

    Precisely, I would like to randomly choose a section (X), assign it the number that corresponds to it (with 1 as the first) and choose in this section an “article” randomly, depending on the number of articles (with 0 as the first) , and give him the number that corresponds to him (Y)

    I managed to create a “random” function, but it just allows me to go to another “section”.
    Here is my try on Jsfiddle which allows me to just choose a section starting with 1.

    # January 15, 2018 at 5:13 pm

    This should do the trick:

    var numItems = $('section'),
    random = Math.floor(Math.random()*numItems.length)+1,
    chance = Math.floor(Math.random()*numItems.eq(random-1).find('article').length);
    # January 15, 2018 at 5:30 pm

    This function returns exactly the right numbers ! Thanks a lot, I appreciate your effort.
    One last thing : I tried to integer it to the fullpage function but it doesn’t work, I tried :

    $.fn.fullpage.moveTo(random + ‘, ‘ + chance);
    $.fn.fullpage.moveTo(random, chance);

    This is not working..

    And I simply need to declare $ .fn.fullpage.moveTo (X, Y);

    # January 15, 2018 at 5:58 pm

    Sorry, my fault, I didn’t copied the right code.
    Thank you very much, have a good week !!

    # January 16, 2018 at 4:27 am

    Same to you, glad it worked.

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

You must be logged in to reply to this topic.