Saltar al contenido principal Salta a docs navegación
in English

Tuñiy

Huk pisi clasekunawan chaymanta JavaScript pluginsniykuwan tukuy proyectoykipi contenidopa rikuyninta tikray.

Imayna llamkan

JavaScript urmachiy plugin llamk'achisqa kachkan rikuchiypaq chaymanta pakaypaq. Botonkuna utaq anclakuna gatillokuna hina llamk'achkanku chaymanta elementokuna específicos kaqman mapeasqa kanku mayqinkunatachus tikranki. Huk elementota urmachispaqa heightkunan chanimanta 0. Imayna CSS kawsachiykunata hap'in chayta qusqa, mana paddinghuk .collapseelemento kaqpi llamk'achiy atikunkichu. Aswanpas, claseta huk sapanchasqa p'istu elemento hina llamk'achiy.

Kay componentepa animación efectonqa prefers-reduced-motionmedios tapuymanta hapirin. Yaykuna qillqaykumanta pisiyachisqa kuyuy t'aqapi qhaway .

Qatina

Uraypi kaq ñit'inakunata ñit'iy huk elementota rikuchinaykipaq chaymanta pakanaykipaq clase tikraykunawan:

  • .collapsecontenidota pakan
  • .collapsingtransiciones nisqapi churakun
  • .collapse.showcontenido nisqatam qawachin

Generalmente, huk ñit'inata data-bs-targetatributowan llamk'achiyta yuyaychayku. Mana semántico qhawaymanta yuyaychasqa kaptinpas, huk t'inkitapas llamk'achiy atikunki hrefatributowan (hinallataq huk role="button"). Iskayninpipas, chay data-bs-toggle="collapse"nisqa kamachisqa kachkan.

Some placeholder content for the collapse component. This panel is hidden by default but revealed when the user activates the relevant trigger.
<p>
  <a class="btn btn-primary" data-bs-toggle="collapse" href="#collapseExample" role="button" aria-expanded="false" aria-controls="collapseExample">
    Link with href
  </a>
  <button class="btn btn-primary" type="button" data-bs-toggle="collapse" data-bs-target="#collapseExample" aria-expanded="false" aria-controls="collapseExample">
    Button with data-bs-target
  </button>
</p>
<div class="collapse" id="collapseExample">
  <div class="card card-body">
    Some placeholder content for the collapse component. This panel is hidden by default but revealed when the user activates the relevant trigger.
  </div>
</div>

Achka metakuna

A <button>icha <a>achka elementokunata rikuchiyta, pakayta atin, shuk akllakwan paypak hreficha data-bs-targetatributo nishkapi rikuchishpa. Achka <button>utaq <a>huk elementota rikuchiyta chaymanta pakayta atin sichus sapankanku paykunap hrefutaq data-bs-targetatributowan referencianku

Some placeholder content for the first collapse component of this multi-collapse example. This panel is hidden by default but revealed when the user activates the relevant trigger.
Some placeholder content for the second collapse component of this multi-collapse example. This panel is hidden by default but revealed when the user activates the relevant trigger.
<p>
  <a class="btn btn-primary" data-bs-toggle="collapse" href="#multiCollapseExample1" role="button" aria-expanded="false" aria-controls="multiCollapseExample1">Toggle first element</a>
  <button class="btn btn-primary" type="button" data-bs-toggle="collapse" data-bs-target="#multiCollapseExample2" aria-expanded="false" aria-controls="multiCollapseExample2">Toggle second element</button>
  <button class="btn btn-primary" type="button" data-bs-toggle="collapse" data-bs-target=".multi-collapse" aria-expanded="false" aria-controls="multiCollapseExample1 multiCollapseExample2">Toggle both elements</button>
</p>
<div class="row">
  <div class="col">
    <div class="collapse multi-collapse" id="multiCollapseExample1">
      <div class="card card-body">
        Some placeholder content for the first collapse component of this multi-collapse example. This panel is hidden by default but revealed when the user activates the relevant trigger.
      </div>
    </div>
  </div>
  <div class="col">
    <div class="collapse multi-collapse" id="multiCollapseExample2">
      <div class="card card-body">
        Some placeholder content for the second collapse component of this multi-collapse example. This panel is hidden by default but revealed when the user activates the relevant trigger.
      </div>
    </div>
  </div>
</div>

Accesibilidad nisqa

aria-expandedAswan allinta qhaway elemento de control nisqaman yapayta . Kay atributo explícitamente kunan estadota elemento colapsible controlman watasqa pantalla ñawiriqkunaman chaymanta rikch'aq yanapakuy tecnologiakunaman apachin. Sichus t'inkisqa elemento ñawpaqmanta wichq'asqa kachkan, kamachiy elementopi atributo chaniyuq kanan tiyan aria-expanded="false". Sichus t'inkisqa elementota kichasqa kananpaq churarqanki ñawpaqmanta showclase kaqwan, aria-expanded="true"kamachiypi churay chaymanta ranti. Plugin kikinmanta kay atributota kamachiypi tikranqa sichus utaq mana llañu elemento kichasqa utaq wichqasqa (JavaScript kaqninta, utaq imaraykuchus llamk'achiq huk kamachiy elementota llamk'achirqa chaymanta kikin llañu elementoman watasqa). Sichus kamachiq elementopa HTML elementon mana huk ñit'inachu (kayhina, huk <a>icha <div>), layarole="button"chay elementoman yapakunan tiyan.

Sichus kamachiy elementoyki huk sapalla llañu elementota qhawachkan – chaymanta data-bs-targetatributo huk akllaqman rikuchichkan – atributota kamachiy elementoman idyapanayki tiyan , chaymanta chay de collapsible elemento kaqmanta. Kunan pantalla ñawiriqkuna chaymanta rikch'aq yanapakuy tecnologiakuna kay atributota llamk'achinku ruwaqkunaman yapa llalliq ñankuna qunankupaq chiqalla purinankupaq kikin elemento collapsible kaqman.aria-controlsid

Reparay Bootstrap kunan ruwaynin mana imaymana akllana teclado tinkiykuna WAI-ARIA Autorización Ruwaykuna 1.1 acordeón patrón kaqpi willasqa kaqta qhawanchu - kaykunata qam kikiyki JavaScript ruwasqawan churanayki tiyan.

Sass

Variables nisqakuna

$transition-collapse:         height .35s ease;

Clases

Collapse transición clasekuna tarikunman kaypi scss/_transitions.scsskaykuna achka componentekuna (collapse chaymanta acordeón) kaqpi rakisqa kasqankurayku.

.collapse {
  &:not(.show) {
    display: none;
  }
}

.collapsing {
  height: 0;
  overflow: hidden;
  @include transition($transition-collapse);
}

Uso

Urmachiy plugin huk pisi clasekunata llamk'achin llasa hoqariyta llamk'achinapaq:

  • .collapsechaypi kaqta pakaykun
  • .collapse.showchaypi kaqta rikuchin
  • .collapsingtikray qallariptin yapasqa, tukuptintaq hurqusqa

Kay clasekunataqa tarinki _transitions.scss.

Atributos de datos nisqawan

Yanapakuylla data-bs-toggle="collapse"chaymanta huk data-bs-targetelementoman kikillanmanta huk utaq achka elementokuna collapsiblekuna kamachiyta churanapaq. Atributo data-bs-targethuk CSS akllanata chaskikun chayman urmachiyta churanapaq. Aswan allinta yapay chay claseta collapsechay elemento collapsible nisqaman. Sichus ñawpaqmanta kichasqa kananta munanki, yapasqa claseta yapay show.

Acordeón hina huñu kamachiyta huk p'istuy kitiman yapanaykipaq, willay laya yapay data-bs-parent="#selector". Kayta ruwaypi qhawanaykipaq demo nisqapi qhaway.

JavaScript nisqawan

Makiwan atichiy kaykunawan:

var collapseElementList = [].slice.call(document.querySelectorAll('.collapse'))
var collapseList = collapseElementList.map(function (collapseEl) {
  return new bootstrap.Collapse(collapseEl)
})

Akllanakuna

Akllanakuna willay layakuna utaq JavaScript kaqnintakama pasayta atikun. Willayta layakunapaq, akllana sutita yapay data-bs-, imaynachus data-bs-parent="".

Suti Niraq Ñawpaqchasqa Willay
parent akllaq | jTapukuy objeto | Elemento DOM nisqa false Sichus tayta mama qusqa, chaymanta llapa t'inkisqa elementokuna nisqa tayta mamap urapi wichq'asqa kanqa mayk'aq kay t'inkisqa imayay rikuchisqa. card(ñawpamanta pacha acordeón ruwayman rikch'akuq - kayqa clasemanta dependen ). Atributoqa churasqa kanan tiyan chay meta collapsible nisqapi.
toggle boolean nisqa true Invocacionpi colapsible elementota tikran

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 .

Aswan willakuypaq JavaScript qillqaykuta qhaway .

Contenidoykita huk elemento collapsible hina activan. Huk akllana akllanakunata chaskikun object.

Ruraqwan huk urmachiy instanciata ruwayta atinki, ahinataq:

var myCollapse = document.getElementById('myCollapse')
var bsCollapse = new bootstrap.Collapse(myCollapse, {
  toggle: false
})
Imayna Willay
toggle Huk ñit'isqa elementota rikuchisqaman icha pakasqaman tikran. Llamaqman kutimun manaraq llalliq elemento chiqamanta rikuchisqa utaq pakasqa kachkaptin (icha manaraq shown.bs.collapseutaq hidden.bs.collapseruway ruwakuchkaptin).
show Huk llalliq elementota rikuchin. Llamaqman kutimun manaraq t'inkisqa elemento chiqamanta rikuchisqa kachkaptin (kayhina, manaraq shown.bs.collapseruway ruwakuchkaptin).
hide Huk llalliq elementota pakan. Llamaqman kutimun manaraq t'uqyakuq elemento chiqamanta pakasqa kachkaptin (kayhina, manaraq hidden.bs.collapseruway ruwakuchkaptin).
dispose Huk elementopa urmayninta chinkachin. (DOM elementopi waqaychasqa willayta hurqun)
getInstance Método estático mayqinchus huk DOM elementowan tinkisqa instanciata urmachiyta jap'iyta atikun, kayhinata llamk'achiy atikunki:bootstrap.Collapse.getInstance(element)
getOrCreateInstance Método estático mayqinchus huk DOM elementowan tinkisqa llalliy instanciata kutichin utaq musuq ruwan mana qallarisqa kaqtin. Chaytaqa kayhinatam servichikuwaq:bootstrap.Collapse.getOrCreateInstance(element)

Eventos nisqakuna

Bootstrap kaqpa urmachiy clase huk pisi ruwaykunata riqsichin urmachiy ruwanaman enganche kaqpaq.

Tipo de evento Willay
show.bs.collapse Kay ruwayqa chaylla rawrarin showinstancia método waqyasqa kaqtin.
shown.bs.collapse Kay ruwayqa llamk'achisqa huk urmachiy elemento ruwaqman rikukuq ruwasqa kaqtin (CSS tikraykunata tukunanta suyanqa).
hide.bs.collapse Kay ruwayqa chaylla llamk'achisqa kachkan mayk'aqchus hidemétodo waqyasqa kachkan.
hidden.bs.collapse Kay ruwayqa llamk'achiqmanta huk urmachiy elemento pakasqa kaptin llamk'achisqa (CSS tikraykunata tukunanta suyanqa).
var myCollapsible = document.getElementById('myCollapsible')
myCollapsible.addEventListener('hidden.bs.collapse', function () {
  // do something...
})