मैं देखता हूं कि आप अंतराल सेट कर सकते हैं लेकिन मैं यह नियंत्रित करना चाहता हूं कि आइटम कितनी तेजी से स्लाइड करते हैं?
// Sets interval...what is transition slide speed?
$('#mainCarousel').carousel({
interval: 3000
});
मैं देखता हूं कि आप अंतराल सेट कर सकते हैं लेकिन मैं यह नियंत्रित करना चाहता हूं कि आइटम कितनी तेजी से स्लाइड करते हैं?
// Sets interval...what is transition slide speed?
$('#mainCarousel').carousel({
interval: 3000
});
जवाबों:
स्पीड को एपीआई द्वारा नियंत्रित नहीं किया जा सकता है। यद्यपि आप सीएसएस को संशोधित कर सकते हैं जो उस के प्रभारी हैं। में carousel.lessफ़ाइल खोजने
.item {
display: none;
position: relative;
.transition(.6s ease-in-out left);
}
और .6sजो आप चाहते हैं उसे बदल दें।
यदि आप उपयोग नहीं करते हैं, तो bootstrap.cssफ़ाइल में खोजें:
.carousel-inner > .item {
position: relative;
display: none;
-webkit-transition: 0.6s ease-in-out left;
-moz-transition: 0.6s ease-in-out left;
-o-transition: 0.6s ease-in-out left;
transition: 0.6s ease-in-out left;
}
और 0.6sआप चाहते हैं कि समय में परिवर्तन । आप नीचे दिए गए फ़ंक्शन कॉल में समय संपादित करना चाह सकते हैं:
.emulateTransitionEnd(2000)
पर bootstrap.jsसमारोह में Carousel.prototype.slide। यह संक्रमण को सिंक्रनाइज़ करता है और संक्रमण समाप्त होने से पहले स्लाइड को रोकने के लिए रोकता है।
EDIT 7/8/2014
जैसा कि @YellowShark ने बताया कि JS में संपादन की अब कोई आवश्यकता नहीं है। केवल सीएसएस परिवर्तन लागू करें।
EDIT 20/8/2015 अब, अपनी css फ़ाइल को संपादित करने के बाद, आपको बस CAROUSEL.TRANSITION_DURATION (bootstrap.js में) या c.TRANSITION_DURATION (यदि आप bootstrap.min.js का उपयोग करते हैं) और इसके अंदर के मान को बदलने की आवश्यकता है। (डिफ़ॉल्ट के लिए 600)। अंतिम मान वही होना चाहिए जो आपने अपनी css फ़ाइल में डाला है (उदाहरण के लिए cs में 10000 = 10000 में .js।
EDIT 16/01/2018 बूटस्ट्रैप 4 के लिए, संक्रमण समय को उदा में बदलने के लिए, 2 सेकंड, जोड़ें
$(document).ready(function() {
jQuery.fn.carousel.Constructor.TRANSITION_DURATION = 2000 // 2 seconds
});
आपकी साइट की JS फ़ाइल और
.carousel-inner .carousel-item {
transition: -webkit-transform 2s ease;
transition: transform 2s ease;
transition: transform 2s ease, -webkit-transform 2s ease;
}
आपकी साइट की CSS फ़ाइल में।
jQuery.fn.carousel.Constructor.TRANSITION_DURATION = 1000;
बस हिंडोला data-intervalमें लिखें div:
<div id="myCarousel" class="carousel slide" data-ride="carousel" data-interval="500">
उदाहरण w3schools से लिया गया ।
data-intervalसमय अवधि निर्धारित करता है जिसके बाद नई स्लाइड चलती है। यह निर्धारित नहीं करता है कि एक स्लाइड को चलने में कितना समय लगता है।
आपको मुख्य DIV में डेटा-अंतराल टैग के रूप में अंतराल सेट करने की आवश्यकता है। यह ठीक काम करेगा और आप अलग-अलग स्लाइड को अलग-अलग समय दे सकते हैं।
<div class="carousel" data-interval="5000">
ट्विटर बूटस्ट्रैप 3 के लिए:
आपको सीएसएस संक्रमण को अन्य उत्तर में निर्दिष्ट के रूप में बदलना होगा:
.carousel-inner > .item {
position: relative;
display: none;
-webkit-transition: 0.6s ease-in-out left;
-moz-transition: 0.6s ease-in-out left;
-o-transition: 0.6s ease-in-out left;
transition: 0.6s ease-in-out left;
}
0.6 सेकंड से 1.5 सेकंड (उदाहरण के लिए)।
लेकिन इसके अलावा, कुछ जावास्क्रिप्ट को बदलना है। Bootstrap.js में एक पंक्ति है:
.emulateTransitionEnd(600)
इसे मिलीसेकंड की संगत राशि में बदला जाना चाहिए। तो 1.5 सेकंड के लिए आप संख्या को 1500 में बदल देंगे:
.emulateTransitionEnd(1500)
एक बात मैंने देखी कि बूटस्ट्रैप 3 शैलियों को जोड़ रहा है .6sऔर दोनों के साथ 0.6s। तो आपको इस तरह अपनी संक्रमण अवधि को स्पष्ट रूप से परिभाषित करने की आवश्यकता हो सकती है (सीएसएस)
.carousel-inner>.item {
-webkit-transition: 0.9s ease-in-out left;
transition: 0.9s ease-in-out left;
-webkit-transition: 0.9s, ease-in-out, left;
-moz-transition: .9s, ease-in-out, left;
-o-transition: .9s, ease-in-out, left;
transition: .9s, ease-in-out, left;
}
बूटस्ट्रैप 4 के साथ, बस इस सीएसएस का उपयोग करें:
.carousel .carousel-item {
transition-duration: 3s;
}
3sअपनी पसंद की अवधि में परिवर्तन करें।
किसी भी बाहरी कोड की जरूरत नहीं data-interval=""विशेषता का उपयोग करें
अधिक जानकारी यात्रा getbootstrap
<div id="carouselExampleCaptions" class="carousel slide" data-ride="carousel" data-interval="2500">
जब आप परिवर्तन गति बदलना चाहते हैं "2500"
यदि आपको इसे बदलने के लिए प्रोग्रामेटिक रूप से करने की आवश्यकता है (उदाहरण के लिए) शायद कुछ हिंडोले के केवल एक पर कुछ शर्तों के आधार पर गति, आप इस तरह से कुछ कर सकते हैं:
यदि Html इस तरह है:
<div id="theSlidesList" class="carousel-inner" role="listbox">
<div id="Slide_00" class="item active"> ...
<div id="Slide_01" class="item"> ...
...
</div>
जावास्क्रिप्ट इस तरह होगा:
$( "#theSlidesList" ).find( ".item" ).css( "-webkit-transition", "transform 1.9s ease-in-out 0s" ).css( "transition", "transform 1.9s ease-in-out 0s" )
अन्य ब्राउज़र शामिल करने के लिए और .css (...) जोड़ें।
एक को शामिल करने bootstrap.min.jsया असम्बद्ध करने के बाद , आप बस एक पैरामीटर के रूप में अंतराल जोड़ सकते हैं जैसा कि
jQuery("#numbers").carousel({'interval':900 });यह मेरे लिए काम करता है
यदि आप बूटस्ट्रैप की js फ़ाइलों को बदलना नहीं चाहते हैं, तो आप सीधे jquery प्लगइन (बूटस्ट्रैप 3.3.6) में वांछित मूल्य को भी इंजेक्ट कर सकते हैं।
यह निश्चित रूप से आवश्यक है, कि हिंडोला js के माध्यम से मैन्युअल रूप से सक्रिय है, सीधे डेटा-राइड विशेषता के माध्यम से नहीं।
उदाहरण के लिए:
var interval = 3500;
$.fn.carousel.Constructor.TRANSITION_DURATION = interval - 500;
elem.carousel({
interval : interval
});
bootstrap.jsऔर "अप्राप्य" बनाने की आवश्यकता नहीं है ..
inकक्षा सेट की जाती है, और जब इसे फिर से हटा दिया जाता है। यदि आप एनीमेशन को छोटा करना चाहते हैं, तो कृपया जाँचें, जहाँ इसे कम फ़ाइलों में परिभाषित किया गया है।
एससीएसएस साथ बूटस्ट्रैप 4 के लिए, आप विन्यास चर अधिलेखित कर सकते हैं $carousel-transition-durationअपने में _variables.scssइस तरह:
$carousel-transition-duration: 2s;
या तत्व के लिए अलग-अलग अवधि निर्धारित की जाती है
.carousel-item {
transition-duration: 2s;
}
अपने विशिष्ट तत्व के अपने सीएसएस / एसएसएस में।
अपने सीएसएस फ़ाइल को संपादित करने के बाद पिछले उत्तरों को पूरक करने के लिए, आपको बस CAROUSEL.TRANSITION_DURATION( bootstrap.js में ) संपादित करने की आवश्यकता है या c.TRANSITION_DURATION(यदि आप bootstrap.min.js का उपयोग करते हैं ) और इसके अंदर मान बदलने के लिए (डिफ़ॉल्ट के लिए 600)। अंतिम मान वही होना चाहिए जो आपने अपनी CSS फ़ाइल में रखा है (उदाहरण के लिए, CSS में 10s = 10000 .js में)।
Carousel.VERSION = '3.3.2'
Carousel.TRANSITION_DURATION = xxxxx /* Your number here*/
Carousel.DEFAULTS = {
interval: 5000 /* you could change this value too, but to add data-interval="xxxx" to your html it's fine too*/
pause: 'hover',
wrap: true,
keyboard: true
}
यदि आप उस गति को संपादित करना चाह रहे हैं, जिसमें बूटस्ट्रैप 3.3.5 के लिए स्लाइड्स अंदर और बाहर आती हैं (अंतरालों को बदलते समय को अंतराल नहीं कहा जाता है)। CDN बूटस्ट्रैप शैलियों को लोड करने के बाद, निम्न वर्गों का उपयोग करके अपने स्वयं के सीएसएस स्टाइलसेट में शैलियों को ओवरराइट करें। 1.5 समय परिवर्तन है।
.carousel-inner > .item {
-webkit-transition: 1.5s ease-in-out ;
-o-transition: 1.5s ease-in-out ;
transition: 1.5s ease-in-out ;
}
.carousel-inner > .item {
-webkit-transition: -webkit-transform 1.5s ease-in-out;
-o-transition: -o-transform 1.5s ease-in-out;
transition: transform 1.5s ease-in-out;
}
उसके बाद, आपको जावास्क्रिप्ट में हिंडोला फ़ंक्शन को बदलने की आवश्यकता होगी। ऐसा करने के लिए आप इसे लोड करने के बाद डिफ़ॉल्ट बूटस्ट्रैप.min.js फ़ंक्शन को अधिलेखित कर देंगे। (मेरी राय में सीधे बूटस्ट्रैप फ़ाइलों को अधिलेखित करना एक अच्छा विचार नहीं है)। इसलिए एक mynewscript.js बनाएं और इसे bootstrap.min.js के बाद लोड करें और नया हिंडोला फ़ंक्शन जोड़ें। केवल एक पंक्ति जिसे आप संपादित करना चाहते हैं वह यह है, Carousel.TRANSITION_DURATION = 1500. 1500 1.5 है। उम्मीद है की यह मदद करेगा।
+function ($) {
'use strict';
// CAROUSEL CLASS DEFINITION
// =========================
var Carousel = function (element, options) {
this.$element = $(element)
this.$indicators = this.$element.find('.carousel-indicators')
this.options = options
this.paused = null
this.sliding = null
this.interval = null
this.$active = null
this.$items = null
this.options.keyboard && this.$element.on('keydown.bs.carousel', $.proxy(this.keydown, this))
this.options.pause == 'hover' && !('ontouchstart' in document.documentElement) && this.$element
.on('mouseenter.bs.carousel', $.proxy(this.pause, this))
.on('mouseleave.bs.carousel', $.proxy(this.cycle, this))
}
Carousel.VERSION = '3.3.5'
Carousel.TRANSITION_DURATION = 1500
Carousel.DEFAULTS = {
interval: 5000,
pause: 'hover',
wrap: true,
keyboard: true
}
Carousel.prototype.keydown = function (e) {
if (/input|textarea/i.test(e.target.tagName)) return
switch (e.which) {
case 37: this.prev(); break
case 39: this.next(); break
default: return
}
e.preventDefault()
}
Carousel.prototype.cycle = function (e) {
e || (this.paused = false)
this.interval && clearInterval(this.interval)
this.options.interval
&& !this.paused
&& (this.interval = setInterval($.proxy(this.next, this), this.options.interval))
return this
}
Carousel.prototype.getItemIndex = function (item) {
this.$items = item.parent().children('.item')
return this.$items.index(item || this.$active)
}
Carousel.prototype.getItemForDirection = function (direction, active) {
var activeIndex = this.getItemIndex(active)
var willWrap = (direction == 'prev' && activeIndex === 0)
|| (direction == 'next' && activeIndex == (this.$items.length - 1))
if (willWrap && !this.options.wrap) return active
var delta = direction == 'prev' ? -1 : 1
var itemIndex = (activeIndex + delta) % this.$items.length
return this.$items.eq(itemIndex)
}
Carousel.prototype.to = function (pos) {
var that = this
var activeIndex = this.getItemIndex(this.$active = this.$element.find('.item.active'))
if (pos > (this.$items.length - 1) || pos < 0) return
if (this.sliding) return this.$element.one('slid.bs.carousel', function () { that.to(pos) }) // yes, "slid"
if (activeIndex == pos) return this.pause().cycle()
return this.slide(pos > activeIndex ? 'next' : 'prev', this.$items.eq(pos))
}
Carousel.prototype.pause = function (e) {
e || (this.paused = true)
if (this.$element.find('.next, .prev').length && $.support.transition) {
this.$element.trigger($.support.transition.end)
this.cycle(true)
}
this.interval = clearInterval(this.interval)
return this
}
Carousel.prototype.next = function () {
if (this.sliding) return
return this.slide('next')
}
Carousel.prototype.prev = function () {
if (this.sliding) return
return this.slide('prev')
}
Carousel.prototype.slide = function (type, next) {
var $active = this.$element.find('.item.active')
var $next = next || this.getItemForDirection(type, $active)
var isCycling = this.interval
var direction = type == 'next' ? 'left' : 'right'
var that = this
if ($next.hasClass('active')) return (this.sliding = false)
var relatedTarget = $next[0]
var slideEvent = $.Event('slide.bs.carousel', {
relatedTarget: relatedTarget,
direction: direction
})
this.$element.trigger(slideEvent)
if (slideEvent.isDefaultPrevented()) return
this.sliding = true
isCycling && this.pause()
if (this.$indicators.length) {
this.$indicators.find('.active').removeClass('active')
var $nextIndicator = $(this.$indicators.children()[this.getItemIndex($next)])
$nextIndicator && $nextIndicator.addClass('active')
}
var slidEvent = $.Event('slid.bs.carousel', { relatedTarget: relatedTarget, direction: direction }) // yes, "slid"
if ($.support.transition && this.$element.hasClass('slide')) {
$next.addClass(type)
$next[0].offsetWidth // force reflow
$active.addClass(direction)
$next.addClass(direction)
$active
.one('bsTransitionEnd', function () {
$next.removeClass([type, direction].join(' ')).addClass('active')
$active.removeClass(['active', direction].join(' '))
that.sliding = false
setTimeout(function () {
that.$element.trigger(slidEvent)
}, 0)
})
.emulateTransitionEnd(Carousel.TRANSITION_DURATION)
} else {
$active.removeClass('active')
$next.addClass('active')
this.sliding = false
this.$element.trigger(slidEvent)
}
isCycling && this.cycle()
return this
}
// CAROUSEL PLUGIN DEFINITION
// ==========================
function Plugin(option) {
return this.each(function () {
var $this = $(this)
var data = $this.data('bs.carousel')
var options = $.extend({}, Carousel.DEFAULTS, $this.data(), typeof option == 'object' && option)
var action = typeof option == 'string' ? option : options.slide
if (!data) $this.data('bs.carousel', (data = new Carousel(this, options)))
if (typeof option == 'number') data.to(option)
else if (action) data[action]()
else if (options.interval) data.pause().cycle()
})
}
var old = $.fn.carousel
$.fn.carousel = Plugin
$.fn.carousel.Constructor = Carousel
// CAROUSEL NO CONFLICT
// ====================
$.fn.carousel.noConflict = function () {
$.fn.carousel = old
return this
}
// CAROUSEL DATA-API
// =================
var clickHandler = function (e) {
var href
var $this = $(this)
var $target = $($this.attr('data-target') || (href = $this.attr('href')) && href.replace(/.*(?=#[^\s]+$)/, '')) // strip for ie7
if (!$target.hasClass('carousel')) return
var options = $.extend({}, $target.data(), $this.data())
var slideIndex = $this.attr('data-slide-to')
if (slideIndex) options.interval = false
Plugin.call($target, options)
if (slideIndex) {
$target.data('bs.carousel').to(slideIndex)
}
e.preventDefault()
}
$(document)
.on('click.bs.carousel.data-api', '[data-slide]', clickHandler)
.on('click.bs.carousel.data-api', '[data-slide-to]', clickHandler)
$(window).on('load', function () {
$('[data-ride="carousel"]').each(function () {
var $carousel = $(this)
Plugin.call($carousel, $carousel.data())
})
})
}(jQuery);
अपने सीएसएस में:
.carousel-item {
transition-duration: 1.5s, 1.5s;
}
ध्यान रखना, हिंडोला के लिए परिभाषित डेटा-अंतराल में समय शामिल है।
आशा है कि इससे सहायता मिलेगी... :)
सभी हिंडोला
<script type="text/javascript">
$(document).ready(function () {
$('.carousel').carousel({
interval: 15000
})
});
</script>
डेटा अंतराल जोड़ें
data-interval="20000"
अपने main.js फ़ाइल या bootstrap.js में, का मूल्य बदल autoplayTimeout
$('.carousel').each(function () {
$(this).owlCarousel({
nav: $(this).data('nav'),
dots: $(this).data('dots'),
loop: $(this).data('loop'),
margin: $(this).data('space'),
center: $(this).data('center'),
dotsSpeed: $(this).data('speed'),
autoplay: $(this).data('autoplay'),
transitionStyle: $(this).data('transition'),
animateOut: $(this).data('animate-out'),
animateIn: $(this).data('animate-in'),
autoplayTimeout: 3000,
responsive: {
0: {
items: 1,
},
400: {
items: $(this).data('slide-sm'),
},
700: {
items: $(this).data('slide-md'),
},
1000: {
items: $(this).data('slide'),
}
}
});
});
यदि ngCarousel मॉड्यूल का उपयोग कर रहे हैं, तो फ़ाइल में अंतराल चर @ ng-bootstrap / ng-bootstrap / carousel-config.js को संपादित करें:
var NgbCarouselConfig = /** @class */ (function () {
function NgbCarouselConfig() {
this.interval = 10000;
this.wrap = true;
...
}
...