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

            Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

            SQL error code 1064 with creating Laravel foreign keysForeign key constraints: When to use ON UPDATE and ON DELETEDropping column with foreign key Laravel error: General error: 1025 Error on renameLaravel SQL Can't create tableLaravel Migration foreign key errorLaravel php artisan migrate:refresh giving a syntax errorSQLSTATE[42S01]: Base table or view already exists or Base table or view already exists: 1050 Tableerror in migrating laravel file to xampp serverSyntax error or access violation: 1064:syntax to use near 'unsigned not null, modelName varchar(191) not null, title varchar(191) not nLaravel cannot create new table field in mysqlLaravel 5.7:Last migration creates table but is not registered in the migration table

            은진 송씨 목차 역사 본관 분파 인물 조선 왕실과의 인척 관계 집성촌 항렬자 인구 같이 보기 각주 둘러보기 메뉴은진 송씨세종실록 149권, 지리지 충청도 공주목 은진현