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;
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
add a comment |
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
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
add a comment |
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
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
javascript
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
add a comment |
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
add a comment |
1 Answer
1
active
oldest
votes
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
add a comment |
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
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
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
add a comment |
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
add a comment |
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
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
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
add a comment |
add a comment |
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.
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.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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
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