Skip to content

Focus on current slider #596

Closed
Closed

Description

@Xxoxo

Hi,
I have 5 sliders on the same page.
When I scroll my page, it's the same slider that has the focus.
Exemple:
http://css-tricks.github.io/AnythingSlider/expand.html#&panel1-1&panel2-1&panel3-1&panel4-1&panel5-1&panel6-1&panel7-1&panel8-1

In this page, the last slider react when using keyboard arrows, not the one we see.
To change that, we have to click on a navigation arrow.

Is there any solution for that ?

Sorry for my english, i'm french :)

Activity

  1. Mottie commented on Dec 19, 2013

    @Mottie
    Contributor

    Hi @Xxoxo!

    Your english is better than my French, so it's okay ;)

    I think the easiest solution would be to use a plugin like inview that detects when an element is visible within the browser window. Or if you have something already in place, you can use this code snippet to detect if the element (slider) is visible in the browser viewport.

    If the slider is visible, then make it active (demo)

    $(function () {
        $('#slider1, #slider2')
        .anythingSlider()
        .bind('inview', function (event, visible) {
            if (visible) {
                $(this).data('AnythingSlider').makeActive();
            }
        });
    });
  2. Xxoxo commented on Dec 19, 2013

    @Xxoxo
    Author

    Thanks a lot @Mottie, that's exactly what I tried to do all my morning without success :)

    Solved !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions