How to create progress bar for Owl Carousel 2?2019 Community Moderator ElectionOwl Carousel - How to pause progress bar at same time as carouselCreate GUID / UUID in JavaScript?How do JavaScript closures work?How to horizontally center a <div>?How do I check if an element is hidden in jQuery?How do I remove a property from a JavaScript object?How do I redirect to another webpage?How to disable text selection highlighting?How to check whether a checkbox is checked in jQuery?How to check whether a string contains a substring in JavaScript?How do I remove a particular element from an array in JavaScript?
Why using two cd commands in bash script does not execute the second command
Why do passenger jet manufacturers design their planes with stall prevention systems?
An Accountant Seeks the Help of a Mathematician
Life insurance that covers only simultaneous/dual deaths
Could the Saturn V actually have launched astronauts around Venus?
What are the possible solutions of the given equation?
At what level can a dragon innately cast its spells?
How to write cleanly even if my character uses expletive language?
Why did it take so long to abandon sail after steamships were demonstrated?
Professor being mistaken for a grad student
How could a female member of a species produce eggs unto death?
RegionDifference for Cylinder and Cuboid
Latest web browser compatible with Windows 98
Official degrees of earth’s rotation per day
Should we release the security issues we found in our product as CVE or we can just update those on weekly release notes?
How could a scammer know the apps on my phone / iTunes account?
Co-worker team leader wants to inject his friend's awful software into our development. What should I say to our common boss?
Can elves maintain concentration in a trance?
Possible Leak In Concrete
Sword in the Stone story where the sword was held in place by electromagnets
How is the Swiss post e-voting system supposed to work, and how was it wrong?
Using "wallow" verb with object
Science-fiction short story where space navy wanted hospital ships and settlers had guns mounted everywhere
Counting certain elements in lists
How to create progress bar for Owl Carousel 2?
2019 Community Moderator ElectionOwl Carousel - How to pause progress bar at same time as carouselCreate GUID / UUID in JavaScript?How do JavaScript closures work?How to horizontally center a <div>?How do I check if an element is hidden in jQuery?How do I remove a property from a JavaScript object?How do I redirect to another webpage?How to disable text selection highlighting?How to check whether a checkbox is checked in jQuery?How to check whether a string contains a substring in JavaScript?How do I remove a particular element from an array in JavaScript?
Official older link for Owl 1 progress bar doesn't even work anymore but I have found working example but also for Owl 1.
I have tried to use the code but I am not able to set it to work with Owl 2
http://codepen.io/anon/pen/GrgEaG
$(document).ready(function()
var time = 7; // time in seconds
var $progressBar,
$bar,
$elem,
isPause,
tick,
percentTime;
//Init the carousel
$("#owl-demo").owlCarousel(
items: 1,
initialized : progressBar,
translate : moved,
drag : pauseOnDragging
);
//Init progressBar where elem is $("#owl-demo")
function progressBar(elem)
$elem = elem;
//build progress bar elements
buildProgressBar();
//start counting
start();
//create div#progressBar and div#bar then prepend to $("#owl-demo")
function buildProgressBar()
$progressBar = $("<div>",
id:"progressBar"
);
$bar = $("<div>",
id:"bar"
);
$progressBar.append($bar).prependTo($elem);
function start()
//reset timer
percentTime = 0;
isPause = false;
//run interval every 0.01 second
tick = setInterval(interval, 10);
;
function interval()
if(isPause === false)
percentTime += 1 / time;
$bar.css(
width: percentTime+"%"
);
//if percentTime is equal or greater than 100
if(percentTime >= 100)
//slide to next item
$elem.trigger('owl.next')
//pause while dragging
function pauseOnDragging()
isPause = true;
//moved callback
function moved()
//clear interval
clearTimeout(tick);
//start again
start();
//uncomment this to make pause on mouseover
// $elem.on('mouseover',function()
// isPause = true;
// )
// $elem.on('mouseout',function()
// isPause = false;
// )
);
#bar
width: 0%;
max-width: 100%;
height: 4px;
background: #7fc242;
#progressBar
width: 100%;
background: #EDEDED;
javascript jquery html css owl-carousel-2
add a comment |
Official older link for Owl 1 progress bar doesn't even work anymore but I have found working example but also for Owl 1.
I have tried to use the code but I am not able to set it to work with Owl 2
http://codepen.io/anon/pen/GrgEaG
$(document).ready(function()
var time = 7; // time in seconds
var $progressBar,
$bar,
$elem,
isPause,
tick,
percentTime;
//Init the carousel
$("#owl-demo").owlCarousel(
items: 1,
initialized : progressBar,
translate : moved,
drag : pauseOnDragging
);
//Init progressBar where elem is $("#owl-demo")
function progressBar(elem)
$elem = elem;
//build progress bar elements
buildProgressBar();
//start counting
start();
//create div#progressBar and div#bar then prepend to $("#owl-demo")
function buildProgressBar()
$progressBar = $("<div>",
id:"progressBar"
);
$bar = $("<div>",
id:"bar"
);
$progressBar.append($bar).prependTo($elem);
function start()
//reset timer
percentTime = 0;
isPause = false;
//run interval every 0.01 second
tick = setInterval(interval, 10);
;
function interval()
if(isPause === false)
percentTime += 1 / time;
$bar.css(
width: percentTime+"%"
);
//if percentTime is equal or greater than 100
if(percentTime >= 100)
//slide to next item
$elem.trigger('owl.next')
//pause while dragging
function pauseOnDragging()
isPause = true;
//moved callback
function moved()
//clear interval
clearTimeout(tick);
//start again
start();
//uncomment this to make pause on mouseover
// $elem.on('mouseover',function()
// isPause = true;
// )
// $elem.on('mouseout',function()
// isPause = false;
// )
);
#bar
width: 0%;
max-width: 100%;
height: 4px;
background: #7fc242;
#progressBar
width: 100%;
background: #EDEDED;
javascript jquery html css owl-carousel-2
Just an FYI, I was trying to figure what was causing such as CPU usage on one of my website page, turns out the progressBar is the culprit.
– Julien Marrec
Jul 11 '17 at 13:11
add a comment |
Official older link for Owl 1 progress bar doesn't even work anymore but I have found working example but also for Owl 1.
I have tried to use the code but I am not able to set it to work with Owl 2
http://codepen.io/anon/pen/GrgEaG
$(document).ready(function()
var time = 7; // time in seconds
var $progressBar,
$bar,
$elem,
isPause,
tick,
percentTime;
//Init the carousel
$("#owl-demo").owlCarousel(
items: 1,
initialized : progressBar,
translate : moved,
drag : pauseOnDragging
);
//Init progressBar where elem is $("#owl-demo")
function progressBar(elem)
$elem = elem;
//build progress bar elements
buildProgressBar();
//start counting
start();
//create div#progressBar and div#bar then prepend to $("#owl-demo")
function buildProgressBar()
$progressBar = $("<div>",
id:"progressBar"
);
$bar = $("<div>",
id:"bar"
);
$progressBar.append($bar).prependTo($elem);
function start()
//reset timer
percentTime = 0;
isPause = false;
//run interval every 0.01 second
tick = setInterval(interval, 10);
;
function interval()
if(isPause === false)
percentTime += 1 / time;
$bar.css(
width: percentTime+"%"
);
//if percentTime is equal or greater than 100
if(percentTime >= 100)
//slide to next item
$elem.trigger('owl.next')
//pause while dragging
function pauseOnDragging()
isPause = true;
//moved callback
function moved()
//clear interval
clearTimeout(tick);
//start again
start();
//uncomment this to make pause on mouseover
// $elem.on('mouseover',function()
// isPause = true;
// )
// $elem.on('mouseout',function()
// isPause = false;
// )
);
#bar
width: 0%;
max-width: 100%;
height: 4px;
background: #7fc242;
#progressBar
width: 100%;
background: #EDEDED;
javascript jquery html css owl-carousel-2
Official older link for Owl 1 progress bar doesn't even work anymore but I have found working example but also for Owl 1.
I have tried to use the code but I am not able to set it to work with Owl 2
http://codepen.io/anon/pen/GrgEaG
$(document).ready(function()
var time = 7; // time in seconds
var $progressBar,
$bar,
$elem,
isPause,
tick,
percentTime;
//Init the carousel
$("#owl-demo").owlCarousel(
items: 1,
initialized : progressBar,
translate : moved,
drag : pauseOnDragging
);
//Init progressBar where elem is $("#owl-demo")
function progressBar(elem)
$elem = elem;
//build progress bar elements
buildProgressBar();
//start counting
start();
//create div#progressBar and div#bar then prepend to $("#owl-demo")
function buildProgressBar()
$progressBar = $("<div>",
id:"progressBar"
);
$bar = $("<div>",
id:"bar"
);
$progressBar.append($bar).prependTo($elem);
function start()
//reset timer
percentTime = 0;
isPause = false;
//run interval every 0.01 second
tick = setInterval(interval, 10);
;
function interval()
if(isPause === false)
percentTime += 1 / time;
$bar.css(
width: percentTime+"%"
);
//if percentTime is equal or greater than 100
if(percentTime >= 100)
//slide to next item
$elem.trigger('owl.next')
//pause while dragging
function pauseOnDragging()
isPause = true;
//moved callback
function moved()
//clear interval
clearTimeout(tick);
//start again
start();
//uncomment this to make pause on mouseover
// $elem.on('mouseover',function()
// isPause = true;
// )
// $elem.on('mouseout',function()
// isPause = false;
// )
);
#bar
width: 0%;
max-width: 100%;
height: 4px;
background: #7fc242;
#progressBar
width: 100%;
background: #EDEDED;
javascript jquery html css owl-carousel-2
javascript jquery html css owl-carousel-2
asked Jan 5 '17 at 9:14
MarkoMarko
4563924
4563924
Just an FYI, I was trying to figure what was causing such as CPU usage on one of my website page, turns out the progressBar is the culprit.
– Julien Marrec
Jul 11 '17 at 13:11
add a comment |
Just an FYI, I was trying to figure what was causing such as CPU usage on one of my website page, turns out the progressBar is the culprit.
– Julien Marrec
Jul 11 '17 at 13:11
Just an FYI, I was trying to figure what was causing such as CPU usage on one of my website page, turns out the progressBar is the culprit.
– Julien Marrec
Jul 11 '17 at 13:11
Just an FYI, I was trying to figure what was causing such as CPU usage on one of my website page, turns out the progressBar is the culprit.
– Julien Marrec
Jul 11 '17 at 13:11
add a comment |
2 Answers
2
active
oldest
votes
the callback functions are not being fired because you're calling them on events that don't exist in owlCarousel 2. The events are prefixed with 'on'.
So if you call them like this:
$("#owl-demo").owlCarousel(
items: 1,
onInitialized : progressBar,
onTranslate : moved,
onDrag : pauseOnDragging
);
The functions will be called. Check the owlCarousel event docs here.
Check out this CodePen for an example progressbar in OwlCarousel using CSS transitions.
Your example in CodePen has really helped me!
– Lorenzo Magon
Nov 3 '17 at 14:46
add a comment |
After running into the need for a progress bar I stumbled across this question, as well as the example of a progress bar with owl-carousel v1.
Using v2.3.3 I came up with the following js/css-animation based solution:
javascript:
const $slider = $('.my-slider')
const SLIDER_TIMEOUT = 10000
$slider.owlCarousel(
items: 1,
nav: false,
dots: false,
autoplay: true,
autoplayTimeout: SLIDER_TIMEOUT,
autoplayHoverPause: true,
loop: true,
onInitialized: (target) =>
const animationStyle = `-webkit-animation-duration:$SLIDER_TIMEOUTms;animation-duration:$SLIDER_TIMEOUTms`
const progressBar = $(
`<div class="slider-progress-bar"><span class="progress" style="$animationStyle"></span></div>`
)
$(target).append(progressBar)
,
onChanged: (type, target) =>
if (type === 'changed')
const $progressBar = $(target).find('.slider-progress-bar')
const clonedProgressBar = $progressBar.clone(true)
$progressBar.remove()
$(target).append(clonedProgressBar)
)
scss
.slider-progress-bar
/* your progress bar styles here */
.progress
height: 4px;
background: red;
animation: sliderProgressBar ease;
.my-slider:hover
.slider-progress-bar .progress
animation-play-state: paused;
@keyframes sliderProgressBar
0%
width: 0%;
100%
width: 100%;
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/3.0/"u003ecc by-sa 3.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%2f41481066%2fhow-to-create-progress-bar-for-owl-carousel-2%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
the callback functions are not being fired because you're calling them on events that don't exist in owlCarousel 2. The events are prefixed with 'on'.
So if you call them like this:
$("#owl-demo").owlCarousel(
items: 1,
onInitialized : progressBar,
onTranslate : moved,
onDrag : pauseOnDragging
);
The functions will be called. Check the owlCarousel event docs here.
Check out this CodePen for an example progressbar in OwlCarousel using CSS transitions.
Your example in CodePen has really helped me!
– Lorenzo Magon
Nov 3 '17 at 14:46
add a comment |
the callback functions are not being fired because you're calling them on events that don't exist in owlCarousel 2. The events are prefixed with 'on'.
So if you call them like this:
$("#owl-demo").owlCarousel(
items: 1,
onInitialized : progressBar,
onTranslate : moved,
onDrag : pauseOnDragging
);
The functions will be called. Check the owlCarousel event docs here.
Check out this CodePen for an example progressbar in OwlCarousel using CSS transitions.
Your example in CodePen has really helped me!
– Lorenzo Magon
Nov 3 '17 at 14:46
add a comment |
the callback functions are not being fired because you're calling them on events that don't exist in owlCarousel 2. The events are prefixed with 'on'.
So if you call them like this:
$("#owl-demo").owlCarousel(
items: 1,
onInitialized : progressBar,
onTranslate : moved,
onDrag : pauseOnDragging
);
The functions will be called. Check the owlCarousel event docs here.
Check out this CodePen for an example progressbar in OwlCarousel using CSS transitions.
the callback functions are not being fired because you're calling them on events that don't exist in owlCarousel 2. The events are prefixed with 'on'.
So if you call them like this:
$("#owl-demo").owlCarousel(
items: 1,
onInitialized : progressBar,
onTranslate : moved,
onDrag : pauseOnDragging
);
The functions will be called. Check the owlCarousel event docs here.
Check out this CodePen for an example progressbar in OwlCarousel using CSS transitions.
answered Jan 5 '17 at 13:56
Gert-Jan KooijmansGert-Jan Kooijmans
31817
31817
Your example in CodePen has really helped me!
– Lorenzo Magon
Nov 3 '17 at 14:46
add a comment |
Your example in CodePen has really helped me!
– Lorenzo Magon
Nov 3 '17 at 14:46
Your example in CodePen has really helped me!
– Lorenzo Magon
Nov 3 '17 at 14:46
Your example in CodePen has really helped me!
– Lorenzo Magon
Nov 3 '17 at 14:46
add a comment |
After running into the need for a progress bar I stumbled across this question, as well as the example of a progress bar with owl-carousel v1.
Using v2.3.3 I came up with the following js/css-animation based solution:
javascript:
const $slider = $('.my-slider')
const SLIDER_TIMEOUT = 10000
$slider.owlCarousel(
items: 1,
nav: false,
dots: false,
autoplay: true,
autoplayTimeout: SLIDER_TIMEOUT,
autoplayHoverPause: true,
loop: true,
onInitialized: (target) =>
const animationStyle = `-webkit-animation-duration:$SLIDER_TIMEOUTms;animation-duration:$SLIDER_TIMEOUTms`
const progressBar = $(
`<div class="slider-progress-bar"><span class="progress" style="$animationStyle"></span></div>`
)
$(target).append(progressBar)
,
onChanged: (type, target) =>
if (type === 'changed')
const $progressBar = $(target).find('.slider-progress-bar')
const clonedProgressBar = $progressBar.clone(true)
$progressBar.remove()
$(target).append(clonedProgressBar)
)
scss
.slider-progress-bar
/* your progress bar styles here */
.progress
height: 4px;
background: red;
animation: sliderProgressBar ease;
.my-slider:hover
.slider-progress-bar .progress
animation-play-state: paused;
@keyframes sliderProgressBar
0%
width: 0%;
100%
width: 100%;
add a comment |
After running into the need for a progress bar I stumbled across this question, as well as the example of a progress bar with owl-carousel v1.
Using v2.3.3 I came up with the following js/css-animation based solution:
javascript:
const $slider = $('.my-slider')
const SLIDER_TIMEOUT = 10000
$slider.owlCarousel(
items: 1,
nav: false,
dots: false,
autoplay: true,
autoplayTimeout: SLIDER_TIMEOUT,
autoplayHoverPause: true,
loop: true,
onInitialized: (target) =>
const animationStyle = `-webkit-animation-duration:$SLIDER_TIMEOUTms;animation-duration:$SLIDER_TIMEOUTms`
const progressBar = $(
`<div class="slider-progress-bar"><span class="progress" style="$animationStyle"></span></div>`
)
$(target).append(progressBar)
,
onChanged: (type, target) =>
if (type === 'changed')
const $progressBar = $(target).find('.slider-progress-bar')
const clonedProgressBar = $progressBar.clone(true)
$progressBar.remove()
$(target).append(clonedProgressBar)
)
scss
.slider-progress-bar
/* your progress bar styles here */
.progress
height: 4px;
background: red;
animation: sliderProgressBar ease;
.my-slider:hover
.slider-progress-bar .progress
animation-play-state: paused;
@keyframes sliderProgressBar
0%
width: 0%;
100%
width: 100%;
add a comment |
After running into the need for a progress bar I stumbled across this question, as well as the example of a progress bar with owl-carousel v1.
Using v2.3.3 I came up with the following js/css-animation based solution:
javascript:
const $slider = $('.my-slider')
const SLIDER_TIMEOUT = 10000
$slider.owlCarousel(
items: 1,
nav: false,
dots: false,
autoplay: true,
autoplayTimeout: SLIDER_TIMEOUT,
autoplayHoverPause: true,
loop: true,
onInitialized: (target) =>
const animationStyle = `-webkit-animation-duration:$SLIDER_TIMEOUTms;animation-duration:$SLIDER_TIMEOUTms`
const progressBar = $(
`<div class="slider-progress-bar"><span class="progress" style="$animationStyle"></span></div>`
)
$(target).append(progressBar)
,
onChanged: (type, target) =>
if (type === 'changed')
const $progressBar = $(target).find('.slider-progress-bar')
const clonedProgressBar = $progressBar.clone(true)
$progressBar.remove()
$(target).append(clonedProgressBar)
)
scss
.slider-progress-bar
/* your progress bar styles here */
.progress
height: 4px;
background: red;
animation: sliderProgressBar ease;
.my-slider:hover
.slider-progress-bar .progress
animation-play-state: paused;
@keyframes sliderProgressBar
0%
width: 0%;
100%
width: 100%;
After running into the need for a progress bar I stumbled across this question, as well as the example of a progress bar with owl-carousel v1.
Using v2.3.3 I came up with the following js/css-animation based solution:
javascript:
const $slider = $('.my-slider')
const SLIDER_TIMEOUT = 10000
$slider.owlCarousel(
items: 1,
nav: false,
dots: false,
autoplay: true,
autoplayTimeout: SLIDER_TIMEOUT,
autoplayHoverPause: true,
loop: true,
onInitialized: (target) =>
const animationStyle = `-webkit-animation-duration:$SLIDER_TIMEOUTms;animation-duration:$SLIDER_TIMEOUTms`
const progressBar = $(
`<div class="slider-progress-bar"><span class="progress" style="$animationStyle"></span></div>`
)
$(target).append(progressBar)
,
onChanged: (type, target) =>
if (type === 'changed')
const $progressBar = $(target).find('.slider-progress-bar')
const clonedProgressBar = $progressBar.clone(true)
$progressBar.remove()
$(target).append(clonedProgressBar)
)
scss
.slider-progress-bar
/* your progress bar styles here */
.progress
height: 4px;
background: red;
animation: sliderProgressBar ease;
.my-slider:hover
.slider-progress-bar .progress
animation-play-state: paused;
@keyframes sliderProgressBar
0%
width: 0%;
100%
width: 100%;
edited Apr 7 '18 at 7:04
answered Apr 7 '18 at 1:56
Brad AdamsBrad Adams
98031629
98031629
add a comment |
add a comment |
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%2f41481066%2fhow-to-create-progress-bar-for-owl-carousel-2%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
Just an FYI, I was trying to figure what was causing such as CPU usage on one of my website page, turns out the progressBar is the culprit.
– Julien Marrec
Jul 11 '17 at 13:11