Carrusel
Huk diapositiva rikuchiy componente elementokuna chawpipi ciclopaq —imaynakuna utaq qillqasqapa diapositivakuna— huk carrusel hina.
Imayna llamkan
Carrusel huk diapositiva rikuchiy huk serie contenido kaqpi ciclo kaqpaq, CSS 3D tikraykunawan ruwasqa chaymanta huk chhika JavaScript kaqwan ruwasqa. Huk qatiq siq'ikunawan, qillqawan utaq sapanchasqa markawan llamk'an. Hinallataqmi yanapakuy ñawpaq/qhipa kamachiykunapaq chaymanta rikuchiqkunata churan.
Navegadorkunapi maypichus API P'anqa Rikuna yanapasqa kachkan, carrusel mana llimp'inqachu mayk'aq web kiti mana ruwaqpaq rikukunchu (kayhina mayk'aq maskaq ñiqi mana llamk'achkanchu, maskaqpa ventananta pisiyachisqa, wakkuna).
prefers-reduced-motion
medios tapuymanta hapirin. Yaykuna qillqaykumanta pisiyachisqa kuyuy t'aqapi qhaway
.
Ama hina kaspa, yachay anidado carruselkuna mana yanapasqachu, chaymanta carruselkuna generalmente mana haykuy kamachiykunawan hunt'asqachu.
Tukuyninpaq, sichus JavaScriptniykumanta pukyuta ruwachkanki, chayta munanutil.js
.
Qatina
Carruselkunaqa manam kikillanmantachu diapositivapa dimensionninkunata normalizanku. Chayhina, yapa yanapakuykunata utaq sapanchasqa estilokuna llamk'achiyta necesitankiman allinta contenidota sayachinaykipaq. Carruselkuna ñawpaq/qhipa kamachiykunata chaymanta rikuchiqkunata yanapaptinkupas, mana sut'imantachu mañasqa kanku. Yanapay hinaspa ruway munasqaykiman hina.
Clase nisqa .active
huknin diapositivaman yapakunan mana chayqa carrusel mana rikukunqachu. Hinallataq huk sapalla id
kaqpi churayta .carousel
chaymanta akllana kamachiykunapaq, aswanta sichus achka carruselkuna huk p'anqapi llamk'achkanki. Control chaymanta rikuchiq elementokuna huk data-target
atributoyuq kananku tiyan (utaq href
t'inkikuna kaqpaq) chaymanta id
elementomanta .carousel
tupan.
Diapositivas solamente
Kaypi huk carrusel con diapositivas solamente. Reparay .d-block
chaymanta .w-100
carrusel siq'ikunapi kayninta maskaqpa ñawpaqmanta siq'i chiqanchayta harkananpaq.
<div id="carouselExampleSlidesOnly" class="carousel slide" data-ride="carousel">
<div class="carousel-inner">
<div class="carousel-item active">
<img src="..." class="d-block w-100" alt="...">
</div>
<div class="carousel-item">
<img src="..." class="d-block w-100" alt="...">
</div>
<div class="carousel-item">
<img src="..." class="d-block w-100" alt="...">
</div>
</div>
</div>
Controles nisqawan
Ñawpaq chaymanta qatiq kamachiykunapi yapay. Elementokunata llamk'achiyta yuyaychayku , ichataq elementokunatapas <button>
llamk'achiyta atinki .<a>
role="button"
<div id="carouselExampleControls" class="carousel slide" data-ride="carousel">
<div class="carousel-inner">
<div class="carousel-item active">
<img src="..." class="d-block w-100" alt="...">
</div>
<div class="carousel-item">
<img src="..." class="d-block w-100" alt="...">
</div>
<div class="carousel-item">
<img src="..." class="d-block w-100" alt="...">
</div>
</div>
<button class="carousel-control-prev" type="button" data-target="#carouselExampleControls" data-slide="prev">
<span class="carousel-control-prev-icon" aria-hidden="true"></span>
<span class="sr-only">Previous</span>
</button>
<button class="carousel-control-next" type="button" data-target="#carouselExampleControls" data-slide="next">
<span class="carousel-control-next-icon" aria-hidden="true"></span>
<span class="sr-only">Next</span>
</button>
</div>
Indicadores nisqawan
Hinallataq, carruselman rikuchiqkunata yapayta atinki, controlkunap ladunpi, chaymanta.
<div id="carouselExampleIndicators" class="carousel slide" data-ride="carousel">
<ol class="carousel-indicators">
<li data-target="#carouselExampleIndicators" data-slide-to="0" class="active"></li>
<li data-target="#carouselExampleIndicators" data-slide-to="1"></li>
<li data-target="#carouselExampleIndicators" data-slide-to="2"></li>
</ol>
<div class="carousel-inner">
<div class="carousel-item active">
<img src="..." class="d-block w-100" alt="...">
</div>
<div class="carousel-item">
<img src="..." class="d-block w-100" alt="...">
</div>
<div class="carousel-item">
<img src="..." class="d-block w-100" alt="...">
</div>
</div>
<button class="carousel-control-prev" type="button" data-target="#carouselExampleIndicators" data-slide="prev">
<span class="carousel-control-prev-icon" aria-hidden="true"></span>
<span class="sr-only">Previous</span>
</button>
<button class="carousel-control-next" type="button" data-target="#carouselExampleIndicators" data-slide="next">
<span class="carousel-control-next-icon" aria-hidden="true"></span>
<span class="sr-only">Next</span>
</button>
</div>
Con capciones
Diapositivaykikunaman qillqakunata yapay mana sasachakuspa .carousel-caption
mayqin ukhupi kaq elementowan .carousel-item
. Aswan huch'uy qhawanakunapi mana sasachu pakasqa kankuman, uraypi rikuchisqa hina, akllana qhaway yanapakuykunawan . Qallariypi pakayku kaywan .d-none
chaymanta kutichimuyku chawpi sayayniyuq dispositivokunapi kaqwan .d-md-block
.
<div id="carouselExampleCaptions" class="carousel slide" data-ride="carousel">
<ol class="carousel-indicators">
<li data-target="#carouselExampleCaptions" data-slide-to="0" class="active"></li>
<li data-target="#carouselExampleCaptions" data-slide-to="1"></li>
<li data-target="#carouselExampleCaptions" data-slide-to="2"></li>
</ol>
<div class="carousel-inner">
<div class="carousel-item active">
<img src="..." class="d-block w-100" alt="...">
<div class="carousel-caption d-none d-md-block">
<h5>First slide label</h5>
<p>Some representative placeholder content for the first slide.</p>
</div>
</div>
<div class="carousel-item">
<img src="..." class="d-block w-100" alt="...">
<div class="carousel-caption d-none d-md-block">
<h5>Second slide label</h5>
<p>Some representative placeholder content for the second slide.</p>
</div>
</div>
<div class="carousel-item">
<img src="..." class="d-block w-100" alt="...">
<div class="carousel-caption d-none d-md-block">
<h5>Third slide label</h5>
<p>Some representative placeholder content for the third slide.</p>
</div>
</div>
</div>
<button class="carousel-control-prev" type="button" data-target="#carouselExampleCaptions" data-slide="prev">
<span class="carousel-control-prev-icon" aria-hidden="true"></span>
<span class="sr-only">Previous</span>
</button>
<button class="carousel-control-next" type="button" data-target="#carouselExampleCaptions" data-slide="next">
<span class="carousel-control-next-icon" aria-hidden="true"></span>
<span class="sr-only">Next</span>
</button>
</div>
Crossfade nisqa
Carruselniykiman yapay .carousel-fade
diapositivakunata huk diapositivapa rantinpi huk descoloramiento transiciónwan kawsachinaykipaq. Carruselpa imayna kananmanta (kayhina, qillqalla diapositivakuna), yapayta .bg-body
utaq wakin ruwasqa CSS .carousel-item
s kaqman allin crossfading kaqpaq munankiman.
<div id="carouselExampleFade" class="carousel slide carousel-fade" data-ride="carousel">
<div class="carousel-inner">
<div class="carousel-item active">
<img src="..." class="d-block w-100" alt="...">
</div>
<div class="carousel-item">
<img src="..." class="d-block w-100" alt="...">
</div>
<div class="carousel-item">
<img src="..." class="d-block w-100" alt="...">
</div>
</div>
<button class="carousel-control-prev" type="button" data-target="#carouselExampleFade" data-slide="prev">
<span class="carousel-control-prev-icon" aria-hidden="true"></span>
<span class="sr-only">Previous</span>
</button>
<button class="carousel-control-next" type="button" data-target="#carouselExampleFade" data-slide="next">
<span class="carousel-control-next-icon" aria-hidden="true"></span>
<span class="sr-only">Next</span>
</button>
</div>
Sapakama .carousel-item
intervalo
data-interval=""
Huk kaqman yapay .carousel-item
mayk'a pachata tardanapaq tikranapaq kikillanmanta bicicletapi puriymanta qatiq kaqman.
<div id="carouselExampleInterval" class="carousel slide" data-ride="carousel">
<div class="carousel-inner">
<div class="carousel-item active" data-interval="10000">
<img src="..." class="d-block w-100" alt="...">
</div>
<div class="carousel-item" data-interval="2000">
<img src="..." class="d-block w-100" alt="...">
</div>
<div class="carousel-item">
<img src="..." class="d-block w-100" alt="...">
</div>
</div>
<button class="carousel-control-prev" type="button" data-target="#carouselExampleInterval" data-slide="prev">
<span class="carousel-control-prev-icon" aria-hidden="true"></span>
<span class="sr-only">Previous</span>
</button>
<button class="carousel-control-next" type="button" data-target="#carouselExampleInterval" data-slide="next">
<span class="carousel-control-next-icon" aria-hidden="true"></span>
<span class="sr-only">Next</span>
</button>
</div>
Desactivar deslizamiento de tocar
Carruselkuna pantalla llachpana dispositivokunapi lluq'i/alliq llalliyta yanapan diapositivakunapura kuyuypaq. data-touch
Kayqa atributo nisqawanmi mana llamk'achisqa kanman . Uraypi kaq ejemplopas mana data-ride
atributota churanchu chaymanta data-interval="false"
chayrayku mana autoplay ruwanchu.
<div id="carouselExampleControlsNoTouching" class="carousel slide" data-touch="false" data-interval="false">
<div class="carousel-inner">
<div class="carousel-item active">
<img src="..." class="d-block w-100" alt="...">
</div>
<div class="carousel-item">
<img src="..." class="d-block w-100" alt="...">
</div>
<div class="carousel-item">
<img src="..." class="d-block w-100" alt="...">
</div>
</div>
<button class="carousel-control-prev" type="button" data-target="#carouselExampleControlsNoTouching" data-slide="prev">
<span class="carousel-control-prev-icon" aria-hidden="true"></span>
<span class="sr-only">Previous</span>
</button>
<button class="carousel-control-next" type="button" data-target="#carouselExampleControlsNoTouching" data-slide="next">
<span class="carousel-control-next-icon" aria-hidden="true"></span>
<span class="sr-only">Next</span>
</button>
</div>
Uso
Atributos de datos nisqawan
Atributos de datos nisqawan yanapachikuy carruselpa maypi kayninta mana sasachakuspalla kamachinaykipaq. data-slide
llalliq simikunata chaskikun prev
utaq next
, chaymi diapositivapa kayninta kunan kasqanman hina tikran. Hukninpiqa, data-slide-to
huk raw diapositiva indiceta carruselman pasananpaq llamk'achiy data-slide-to="2"
, chaymi diapositivapa kayninta huk indice particularman tikran ,wan qallarispa 0
.
Atributo data-ride="carousel"
nisqaqa huk carrusel nisqa p'anqa kargamanta qallarispa kawsachiq hina markanapaqmi llamk'achisqa. Sichus mana data-ride="carousel"
carruselniyki qallariypaq llamk'achkankichu, qam kikiyki qallarichinayki tiyan. Mana llamk'achiy atikunmanchu (redundante chaymanta mana necesario) sut'i JavaScript qallariywan kikin carrusel kaqwan kuskachasqa.
JavaScript nisqawan
Llama a carrusel manualmente con:
$('.carousel').carousel()
Akllanakuna
Akllanakuna willay layakuna utaq JavaScript kaqnintakama pasayta atikun. Willayta layakunapaq, akllana sutita yapay data-
, imaynachus data-interval=""
.
Suti | Niraq | Ñawpaqchasqa | Willay |
---|---|---|---|
intervalo nisqa | yupay | 5000 nisqa | Huk imapas kikillanmanta bicicletapi purichiymanta hayk'a pacha tardanapaq. Sichus false , carrusel mana kikillanmantachu ciclopi purinqa. |
teclado nisqa | boolean nisqa | chiqaq | Sichus carrusel tecladopi sucedesqanwan reaccionananchu icha manachu. |
suyay | q'aytu | boolean nisqa | 'hover' nisqa. | Sichus churasqa kachkan Llachpanapaq atichisqa dispositivokunapi, , kaqpi churasqa kaqtin |
purikuy | qaytu | pantasqa | Kikinmanta carruselta pukllan chaymanta llamk'achiq makiwan ñawpaq kaq imata muyuchisqanmanta. Sichus churasqa 'carousel' , autoplay carrusel cargapi. |
matiy | boolean nisqa | chiqaq | Carrusel sapa kutilla bicicletapi purinan icha sinchi sayayniyuq kanan icha manachu. |
tuqpina | boolean nisqa | chiqaq | Sichus carrusel yanapanan tiyan lluq'i/alliq swipe interacciones pantalla táctil dispositivokunapi. |
Métodos
Métodos y transiciones asíncronas
Llapan API ruwanakuna mana sink'uyuq kanku chaymanta huk tikrayta qallarinku . Paykunaqa kutinku waqyaqman chaylla transición qallarisqa ichaqa manaraq tukukuchkaptin . Chaymantapas, huk tikray componente kaqpi huk método waqyay mana qhawasqachu kanqa .
.carousel(options)
Carruselta huk opcional akllanakunawan object
qallarichin chaymanta bicicletapi puriyta qallarikun imakuna kaqnintakama.
$('.carousel').carousel({
interval: 2000
})
.carousel('cycle')
Carrusel nisqa imakunatapas lluq’imanta pañaman muyurin.
.carousel('pause')
Carruselta imakuna chawpinta bicicletapi purinanta harkan.
.carousel(number)
Carruselta huk marco particularman muyuchin (0 kaqpi, huk matrizman rikch'akuq). Llamaqman kutimun manaraq imachus munasqa rikuchisqa kachkaptin (icha manaraq slid.bs.carousel
ruway ruwakuchkaptin).
.carousel('prev')
Ñawpaq kaq kaqman muyurin. Llamaqman kutimun manaraq ñawpaq kaq rikuchisqa kachkaptin (icha manaraq slid.bs.carousel
ruway ruwakuchkaptin).
.carousel('next')
Qatiqnin kaqman ciclokuna. Llamaqman kutimun manaraq qatiq imapas rikuchisqa kachkaptin (icha manaraq slid.bs.carousel
ruway ruwakuchkaptin).
.carousel('dispose')
Huk elementopa carruselnintam chinkachin.
.carousel('nextWhenVisible')
Ama bicicletapi carruselta qatiqninman puriychu p'anqa mana rikukuptin utaq carrusel utaq tayta-maman mana rikukuptin. Llamaqman kutimun manaraq qatiq imapas rikuchisqa kachkaptin (icha manaraq slid.bs.carousel
ruway ruwakuchkaptin).
.carousel('to')
Carruselta huk marco particularman muyuchin (0 kaqpi, huk matrizman rikch'akuq). Llamaqman kutimun manaraq qatiq imapas rikuchisqa kachkaptin (icha manaraq slid.bs.carousel
ruway ruwakuchkaptin).
Eventos nisqakuna
Bootstrap kaqpa carrusel clase iskay ruwaykunata rikuchin carrusel ruwanaman enganche kaqpaq. Iskaynin ruwaykuna kay yapasqa propiedadesniyuq kanku:
direction
: Carrusel maymanchus llimp’isqan (yaqapas"left"
utaq"right"
).relatedTarget
: DOM elemento mayqinchus llamk'aq elemento hina maychus kananman llimp'isqa kachkan.from
: Kunan kaq imayaypa indice nisqato
: Qatiqninpi kaqpa indice nisqa
Llapan carrusel ruwaykuna kikin carruselpi (ichataq chay <div class="carousel">
).
Tipo de Evento | Willay |
---|---|
diapositiva.bs.carrusel nisqa | Kay ruwayqa chaylla rawrarin mayk'aq slide instancia método waqyasqa. |
llimp’isqa.bs.carrusel | Kay sucesoqa carrusel diapositiva transicionninta tukuruptinmi rawrachisqa. |
$('#myCarousel').on('slide.bs.carousel', function () {
// do something...
})
Cambio de duración de transición
Kay tikray unayniyuq .carousel-item
kay Sass tikraqwan manaraq huñuchkaspa utaq sapanchasqa estilokunawan tikrasqa kanman $carousel-transition
sichus huñusqa CSS kaqwan llamk'achkanki. Achka tikraykunata churaptinkuqa, tikray tikray ñawpaqta riqsichisqa kananpaq qhaway (kayhina transition: transform 2s ease, opacity .5s ease-out
).