Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums JavaScript JS Media Query

  • This topic is empty.
Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #44295
    iknowdavehouse
    Participant

    Although my CSS is getting better I just simply do not understand javascript yet.

    I am using a slider on a simple (one break point) responsive micro site.

    All I want to do is add a variable on the js running the slider so

    Desktop

    $(function () {

    $(“.rslides”).responsiveSlides({
    auto: true,
    pager: true,
    nav: false,
    speed: 1000,

    });

    });

    And then at the first breakpoint I just want to swap the pager and nav round:

    $(function () {

    $(“.rslides”).responsiveSlides({
    auto: true,
    pager: false,
    nav: true,
    speed: 1000,

    });

    });

    So how do add a media query to this script so that I can swap between these two options?

    Thanks

    #132697
    CrocoDillon
    Participant

    You can use something like this:

    $(function () {
    var isDesktop = $(window).width() > 1024;

    $(“.rslides”).responsiveSlides({
    auto: true,
    pager: isDesktop,
    nav: !isDesktop,
    speed: 1000,
    });

    });

    But to make it support resizing depends on the plugin options (easiest would be to re-run the initialization, you could try if that works).

    #132712
    iknowdavehouse
    Participant

    thanks, this was a perfect solution for this particular site. A real help, thank you!

Viewing 3 posts - 1 through 3 (of 3 total)
  • The forum ‘JavaScript’ is closed to new topics and replies.