Create a carousel with automovement - issue with working with time/pause all the timejCarouselLite reset autoscroll intervalJquery show and hide elements according to positionClean math solution to iterate circular carouselHow do I make the click function on my carousel work when items are appended?Javascript Carousel - Issue adding QueueHow to add a pause/play function to a running setInterval?Multi slides carouselDisplay elapsed seconds on a button which also activates a functionCreating a Carousel in Phaser.ioJavascript- How to reset button counter when timer reaches 0

Number of aircraft to operate in an airline company

What's the biggest difference between these two photos?

Why was "leaping into the river" a valid trial outcome to prove one's innocence?

Do any aircraft carry boats?

A medieval fantasy adventurer lights a torch in a 100% pure oxygen room. What happens?

What does "synoptic" mean in avionics?

Is there a basic list of ways in which a low-level Rogue can get advantage for sneak attack?

How can I protect myself in case of a human attack like the murders of the hikers Jespersen and Ueland in Morocco?

My favorite color is blue what is your favorite color?

Will replacing a fake visa with a different fake visa cause me problems when applying for a legal study permit?

Is there a standard terminology for female equivalents of terms such as 'Kingdom' and if so, what are the most common terms?

RP Automatic Updates

Might have gotten a coworker sick, should I address this?

Georgian capital letter “Ⴒ” (“tar”) in pdfLaTeX

Writing a love interest for my hero

Why is the the worst case for this function O(n^2)?

Are there any instances of members of different Hogwarts houses coupling up and marrying each other?

What is this dollar sign ($) icon in my Menu Bar?

Can I say "I will encrypt something" if I hash something?

Why does F + F' = 1?

Job offer without any details but asking me to withdraw other applications - is it normal?

What was the first LISP compiler?

Are there take-over requests from autopilots?

Is English tonal for some words, like "permit"?



Create a carousel with automovement - issue with working with time/pause all the time


jCarouselLite reset autoscroll intervalJquery show and hide elements according to positionClean math solution to iterate circular carouselHow do I make the click function on my carousel work when items are appended?Javascript Carousel - Issue adding QueueHow to add a pause/play function to a running setInterval?Multi slides carouselDisplay elapsed seconds on a button which also activates a functionCreating a Carousel in Phaser.ioJavascript- How to reset button counter when timer reaches 0






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








1















I'm trying to do a sort of a multi element carousel:



I implemented left and right but I have problems with auto:



function addCarouselListener() 
data.forEach(function (carousel)
carousel.previous.addEventListener('click', moveLeft);
carousel.next.addEventListener('click', moveRight);
);



function autoslide() {
var max =10, visible=6, count=visible;
max = 10

while (count < max)
moveRight();
count +=1;


if (count=max) // go back
while(count > visible)
moveLeft( )
count -=1;




First this is not really working always, I need to always work and have a timer.
Second, I need to pause if the user click on left,right(previous/next).



Please don't send me links to already done scripts, because I want to understand, plus I need something more custom.










share|improve this question
























  • Your question is really hard to understand, are you using some javascript library? What is your actual problem? The code you posted does not do much of anything, I'm afraid nobody can help you with this minimal information.

    – Esko
    Mar 28 at 8:39

















1















I'm trying to do a sort of a multi element carousel:



I implemented left and right but I have problems with auto:



function addCarouselListener() 
data.forEach(function (carousel)
carousel.previous.addEventListener('click', moveLeft);
carousel.next.addEventListener('click', moveRight);
);



function autoslide() {
var max =10, visible=6, count=visible;
max = 10

while (count < max)
moveRight();
count +=1;


if (count=max) // go back
while(count > visible)
moveLeft( )
count -=1;




First this is not really working always, I need to always work and have a timer.
Second, I need to pause if the user click on left,right(previous/next).



Please don't send me links to already done scripts, because I want to understand, plus I need something more custom.










share|improve this question
























  • Your question is really hard to understand, are you using some javascript library? What is your actual problem? The code you posted does not do much of anything, I'm afraid nobody can help you with this minimal information.

    – Esko
    Mar 28 at 8:39













1












1








1








I'm trying to do a sort of a multi element carousel:



I implemented left and right but I have problems with auto:



function addCarouselListener() 
data.forEach(function (carousel)
carousel.previous.addEventListener('click', moveLeft);
carousel.next.addEventListener('click', moveRight);
);



function autoslide() {
var max =10, visible=6, count=visible;
max = 10

while (count < max)
moveRight();
count +=1;


if (count=max) // go back
while(count > visible)
moveLeft( )
count -=1;




First this is not really working always, I need to always work and have a timer.
Second, I need to pause if the user click on left,right(previous/next).



Please don't send me links to already done scripts, because I want to understand, plus I need something more custom.










share|improve this question














I'm trying to do a sort of a multi element carousel:



I implemented left and right but I have problems with auto:



function addCarouselListener() 
data.forEach(function (carousel)
carousel.previous.addEventListener('click', moveLeft);
carousel.next.addEventListener('click', moveRight);
);



function autoslide() {
var max =10, visible=6, count=visible;
max = 10

while (count < max)
moveRight();
count +=1;


if (count=max) // go back
while(count > visible)
moveLeft( )
count -=1;




First this is not really working always, I need to always work and have a timer.
Second, I need to pause if the user click on left,right(previous/next).



Please don't send me links to already done scripts, because I want to understand, plus I need something more custom.







javascript






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Mar 28 at 8:25









user3541631user3541631

1,2923 gold badges18 silver badges43 bronze badges




1,2923 gold badges18 silver badges43 bronze badges















  • Your question is really hard to understand, are you using some javascript library? What is your actual problem? The code you posted does not do much of anything, I'm afraid nobody can help you with this minimal information.

    – Esko
    Mar 28 at 8:39

















  • Your question is really hard to understand, are you using some javascript library? What is your actual problem? The code you posted does not do much of anything, I'm afraid nobody can help you with this minimal information.

    – Esko
    Mar 28 at 8:39
















Your question is really hard to understand, are you using some javascript library? What is your actual problem? The code you posted does not do much of anything, I'm afraid nobody can help you with this minimal information.

– Esko
Mar 28 at 8:39





Your question is really hard to understand, are you using some javascript library? What is your actual problem? The code you posted does not do much of anything, I'm afraid nobody can help you with this minimal information.

– Esko
Mar 28 at 8:39












1 Answer
1






active

oldest

votes


















1
















I can clearly tell you that this line doesn't work as you'd expect :



if (count = max)



To compare equality between two variables you must use == or === if you'd like to also compare their type.



Also if you just do that like this, the slider will loop so fast that your browser will probably crash.



You want to use setInterval()



Here is a simple not-tested example :



var direction = 'right'
var current_position = 0
var max = 10
var delay = 500
var timer = false

function move_slider()
if(direction == 'right')
current_position += 1
if(direction == 'left')
current_position -= 1

// move the slider


function auto_slide()
console.log(current_position, direction)
move_slider()

if(current_position <= 0)
direction = 'right'
if(current_position >= max)
direction = 'left'


function set_auto_mode()
timer = window.setInterval(auto_slide, delay)


function unset_auto_mode()
window.clearInterval(timer)
timer = false






share|improve this answer
























    Your Answer






    StackExchange.ifUsing("editor", function ()
    StackExchange.using("externalEditor", function ()
    StackExchange.using("snippets", function ()
    StackExchange.snippets.init();
    );
    );
    , "code-snippets");

    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "1"
    ;
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function()
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled)
    StackExchange.using("snippets", function()
    createEditor();
    );

    else
    createEditor();

    );

    function createEditor()
    StackExchange.prepareEditor(
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader:
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/4.0/"u003ecc by-sa 4.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    ,
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    );



    );














    draft saved

    draft discarded
















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55393012%2fcreate-a-carousel-with-automovement-issue-with-working-with-time-pause-all-the%23new-answer', 'question_page');

    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    1
















    I can clearly tell you that this line doesn't work as you'd expect :



    if (count = max)



    To compare equality between two variables you must use == or === if you'd like to also compare their type.



    Also if you just do that like this, the slider will loop so fast that your browser will probably crash.



    You want to use setInterval()



    Here is a simple not-tested example :



    var direction = 'right'
    var current_position = 0
    var max = 10
    var delay = 500
    var timer = false

    function move_slider()
    if(direction == 'right')
    current_position += 1
    if(direction == 'left')
    current_position -= 1

    // move the slider


    function auto_slide()
    console.log(current_position, direction)
    move_slider()

    if(current_position <= 0)
    direction = 'right'
    if(current_position >= max)
    direction = 'left'


    function set_auto_mode()
    timer = window.setInterval(auto_slide, delay)


    function unset_auto_mode()
    window.clearInterval(timer)
    timer = false






    share|improve this answer





























      1
















      I can clearly tell you that this line doesn't work as you'd expect :



      if (count = max)



      To compare equality between two variables you must use == or === if you'd like to also compare their type.



      Also if you just do that like this, the slider will loop so fast that your browser will probably crash.



      You want to use setInterval()



      Here is a simple not-tested example :



      var direction = 'right'
      var current_position = 0
      var max = 10
      var delay = 500
      var timer = false

      function move_slider()
      if(direction == 'right')
      current_position += 1
      if(direction == 'left')
      current_position -= 1

      // move the slider


      function auto_slide()
      console.log(current_position, direction)
      move_slider()

      if(current_position <= 0)
      direction = 'right'
      if(current_position >= max)
      direction = 'left'


      function set_auto_mode()
      timer = window.setInterval(auto_slide, delay)


      function unset_auto_mode()
      window.clearInterval(timer)
      timer = false






      share|improve this answer



























        1














        1










        1









        I can clearly tell you that this line doesn't work as you'd expect :



        if (count = max)



        To compare equality between two variables you must use == or === if you'd like to also compare their type.



        Also if you just do that like this, the slider will loop so fast that your browser will probably crash.



        You want to use setInterval()



        Here is a simple not-tested example :



        var direction = 'right'
        var current_position = 0
        var max = 10
        var delay = 500
        var timer = false

        function move_slider()
        if(direction == 'right')
        current_position += 1
        if(direction == 'left')
        current_position -= 1

        // move the slider


        function auto_slide()
        console.log(current_position, direction)
        move_slider()

        if(current_position <= 0)
        direction = 'right'
        if(current_position >= max)
        direction = 'left'


        function set_auto_mode()
        timer = window.setInterval(auto_slide, delay)


        function unset_auto_mode()
        window.clearInterval(timer)
        timer = false






        share|improve this answer













        I can clearly tell you that this line doesn't work as you'd expect :



        if (count = max)



        To compare equality between two variables you must use == or === if you'd like to also compare their type.



        Also if you just do that like this, the slider will loop so fast that your browser will probably crash.



        You want to use setInterval()



        Here is a simple not-tested example :



        var direction = 'right'
        var current_position = 0
        var max = 10
        var delay = 500
        var timer = false

        function move_slider()
        if(direction == 'right')
        current_position += 1
        if(direction == 'left')
        current_position -= 1

        // move the slider


        function auto_slide()
        console.log(current_position, direction)
        move_slider()

        if(current_position <= 0)
        direction = 'right'
        if(current_position >= max)
        direction = 'left'


        function set_auto_mode()
        timer = window.setInterval(auto_slide, delay)


        function unset_auto_mode()
        window.clearInterval(timer)
        timer = false







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Mar 28 at 8:39









        LoïcLoïc

        8,2641 gold badge15 silver badges38 bronze badges




        8,2641 gold badge15 silver badges38 bronze badges





















            Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.







            Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.




















            draft saved

            draft discarded















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid …


            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.

            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55393012%2fcreate-a-carousel-with-automovement-issue-with-working-with-time-pause-all-the%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            How to preserve electronics (computers, tablets and phones) for hundreds of years Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 23, 2019 at 23:30 UTC (7:30pm US/Eastern) The network's official Twitter account is up and running again. What content…How might modern humans leave a message for 50,000 years?How would an aquatic race develop computers?How do we make computers care for human life?Keeping supplies for 1000 yearsWhat will cell phones become in 100 years?What body armor protects against a laser?Could a society attain 1800s technology if limited to using copper and bronze?Electricity power (magic) and electronicsScavenging metal resources in post-apocalypse after 100 yearsWhy would precursors create devices that can survive and still work after hundreds of years?

            155 수학 과학 기타 둘러보기 메뉴eh추가해eh문서를 완성해

            Convert JSON to MapSimplest way to convert a string representing JSON array into Java array List of key value pairsHow to take String JSON values into HashMapConvert a JSON String to a HashMapCreating BSON object from JSON stringJSONObject - How to get a value ?Better Map ConstructorReading JSON from Url javaUpdate columns if input values are not null otherwise ignore and keep the existing values of column in databaseHow to store object represented as Json string into Couchbase Lite?Go JSON into MapHow do I efficiently iterate over each entry in a Java Map?Sort a Map<Key, Value> by valuesHow to round a number to n decimal places in JavaCan comments be used in JSON?How do I read / convert an InputStream into a String in Java?How can I pretty-print JSON in a shell script?What is the correct JSON content type?How can I deserialize JSON to a simple Dictionary<string,string> in ASP.NET?Why does Google prepend while(1); to their JSON responses?Parse JSON in JavaScript?