I-Carousel
Icandelo lomboniso wesilayidi sokuhamba ngebhayisekile kwizinto-imifanekiso okanye izilayidi zombhalo-njengecarousel.
Ingaba isebenza kanjani
I-carousel ngumboniso wesilayidi sokuhamba ngebhayisikile ngoluhlu lomxholo, owakhiwe nge-CSS 3D yokuguqula kunye nentwana yeJavaScript. Isebenza ngothotho lwemifanekiso, isicatshulwa, okanye uphawu lwesiko. Ikwabandakanya inkxaso yolawulo lwangaphambili / olulandelayo kunye nezalathi.
Kwiziphequluli apho i- Page Visibility API ixhaswa khona, i-carousel iya kuphepha ukutyibilika xa iphepha lewebhu lingabonakali kumsebenzisi (njengaxa ithebhu ye-browser ingasebenzi, iwindow yesiphequluli iyancitshiswa, njl. njl.).
Isiphumo soopopayi seli candelo sixhomekeke prefers-reduced-motion
kumbuzo wemidiya. Jonga icandelo leentshukumo ezincitshisiweyo kuxwebhu lwethu lofikelelo .
Nceda uqaphele ukuba iicarousels ezifakwe kwindlwane azixhaswanga, kwaye iicarousels azihambelani nemigangatho yokufikeleleka.
Okokugqibela, ukuba wakha iJavaScript yethu kwimvelaphi, ifunautil.js
.
Umzekelo
Iicarousels azizenzeli ngokuzenzekelayo imilinganiselo yesilayidi. Ngaloo ndlela, kunokufuneka usebenzise izixhobo ezongezelelweyo okanye izitayile zesiko ukuze ulinganise ngokufanelekileyo umxholo. Ngelixa ii-carousels zixhasa ulawulo lwangaphambili/olulandelayo kunye nezalathi, azifuneki ngokucacileyo. Yongeza kwaye wenze ngokwezifiso njengoko ubona kufanelekile.
Iklasi .active
kufuneka yongezwe kwesinye sezilayidi kungenjalo i-carousel ayiyi kubonakala. Kwakhona qiniseka ukuseta i-id eyodwa kulawulo .carousel
olukhethwayo, ngakumbi ukuba usebenzisa iicarousel ezininzi kwiphepha elinye. Ulawulo kunye neempawu zesalathisi kufuneka data-target
zibenophawu (okanye href
amakhonkco) ahambelana ne-id .carousel
yesiqalelo.
Izilayidi kuphela
Nantsi i-carousel enezilayidi kuphela. Qaphela ubukho .d-block
kunye .w-100
nemifanekiso ye-carousel ukunqanda ulungelelwaniso lomfanekiso olungagqibekanga lwesikhangeli.
Ngolawulo
Ukongeza kulawulo lwangaphambili nolulandelayo:
Ngezalathi
Unokongeza izikhombisi kwi-carousel, ecaleni kolawulo, kwakhona.
Neentloko-magama
Yongeza ii-captions kwizilayidi zakho ngokulula ngento .carousel-caption
engaphakathi kuyo nayiphi na .carousel-item
. Zinokufihlwa ngokulula kwizibuko zokujonga ezincinci, njengoko kubonisiwe ngezantsi, ngezixhobo ezikhethwayo zokubonisa . Sizifihla ekuqaleni .d-none
kwaye sizibuyisele kwizixhobo ezinobungakanani obuphakathi kunye .d-md-block
.
I-Crossfade
Yongeza .carousel-fade
kwi-carousel yakho ukuze uphilise izilayidi ngotshintsho olumnyama endaweni yesilayidi.
.carousel-item
Ikhefu lomntu ngamnye
Yongeza data-interval=""
kwi- .carousel-item
a ukutshintsha ubungakanani bexesha lokulibazisa phakathi kokukhwela ibhayisekile ngokuzenzekelayo ukuya kwinto elandelayo.
Ukusetyenziswa
Ngeempawu zedatha
Sebenzisa iimpawu zedatha ukulawula ngokulula indawo ye-carousel. data-slide
yamkela amagama angundoqo prev
okanye next
, eguqula indawo yesilayidi ngokunxulumene nendawo yaso yangoku. Kungenjalo, sebenzisa data-slide-to
ukudlulisa isalathiso sesilayidi ekrwada kwicarousel data-slide-to="2"
, etshintsha indawo yesilayidi kwisalathiso esithile esiqala nge 0
.
Uphawu data-ride="carousel"
loyelelwano lusetyenziselwa ukuphawula i-carousel njengento ephilayo ukuqala kumthwalo wephepha. Ukuba awusebenzisi data-ride="carousel"
ukuqalisa i-carousel yakho, kufuneka uyiqalise ngokwakho. Ayinakusetyenziswa ngokudityaniswa ne (ingafunekiyo nengafunekiyo) iJavaScript ecacileyo yokuqaliswa kwecarousel enye.
NgeJavaScript
Fowunela i-carousel ngesandla nge:
Iinketho
Iinketho zinokugqithiswa ngeempawu zedatha okanye iJavaScript. Kuphawu lwedatha, faka igama lokhetho ku data-
, njengakwi data-interval=""
.
Igama | Uhlobo | Ukuhlala kukho | Inkcazo |
---|---|---|---|
isithuba | inani | 5000 | Ubungakanani bexesha lokulibaziseka phakathi kokubhayisela ngokuzenzekelayo into. Ukuba ayiyonyani, i-carousel ayiyi kujikeleza ngokuzenzekelayo. |
ikhibhodi | boolean | yinyani | Nokuba i-carousel kufuneka isabele kwiziganeko ze-keyboard. |
nqumama | umtya | boolean | "bhabha" | Ukuba imiselwe Kwizixhobo ezisebenza ngokuchukumisa, xa zimiselwe |
khwela | umtya | bubuxoki | Udlala ngokuzenzekelayo i-carousel emva kokuba umsebenzisi ajikelezise into yokuqala. Ukuba "i-carousel", idlala ngokuzenzekelayo i-carousel kumthwalo. |
usonga | boolean | yinyani | Nokuba i-carousel kufuneka iqhubeke ijikeleza okanye ibe neendawo zokumisa nzima. |
touch | boolean | yinyani | Nokuba i-carousel kufuneka ixhase ukuswayipha ekhohlo/ekunene kwizixhobo zescreen sokuchukumisa. |
Iindlela
Iindlela ze-Asynchronous kunye notshintsho
Zonke iindlela ze-API zi -asynchronous kwaye ziqala utshintsho . Babuyela kumnxeba ngokukhawuleza nje ukuba inguqu iqalisiwe kodwa ingekapheli . Ukongeza, ukufowunelwa kwendlela kwicandelo lenguquko kuya kuhoywa .
.carousel(options)
Uqalisa i-carousel ngeendlela ozikhethelayo object
kwaye uqalise ukukhwela ibhayisekile kwizinto.
.carousel('cycle')
Ujikeleza izinto zecarousel ukusuka ekhohlo ukuya ekunene.
.carousel('pause')
Imisa ikhareshi ekukhweleni ibhayisekile kwizinto.
.carousel(number)
Ujikelezisa i-carousel kwisakhelo esithile (i-0 esekelwe, efana noluhlu). Ubuyela kumnxeba phambi kokuba into ekujoliswe kuyo iboniswe (okt phambi kokuba slid.bs.carousel
isiganeko senzeke).
.carousel('prev')
Imijikelo ukuya kwinto yangaphambili. Ubuyela kumnxeba phambi kokuba kuboniswe into yangaphambili (okt phambi kokuba slid.bs.carousel
isiganeko senzeke).
.carousel('next')
Biyela ukuya kwinto elandelayo. Ubuyela kumnxeba phambi kokuba kuboniswe into elandelayo (okt phambi kokuba slid.bs.carousel
isiganeko senzeke).
.carousel('dispose')
Uyonakalisa i-carousel yento.
.carousel('nextWhenVisible')
Musa ukujikela i-carousel ukuya kwelinye xa iphepha lingabonakali okanye i-carousel okanye umzali wayo engabonakali. Ubuyela kumnxeba phambi kokuba kuboniswe into elandelayo (okt phambi kokuba slid.bs.carousel
isiganeko senzeke).
.carousel('to')
Ujikelezisa i-carousel kwisakhelo esithile (i-0 esekelwe, efana noluhlu). Ubuyela kumnxeba phambi kokuba kuboniswe into elandelayo (okt phambi kokuba slid.bs.carousel
isiganeko senzeke).
Iziganeko
Iklasi ye-carousel ye-Bootstrap iveza iminyhadala emibini yokuhuka ekusebenzeni kwecarousel. Zombini ezi ziganeko zineempawu ezongezelelweyo zilandelayo:
direction
: Isalathiso apho i-carousel ishelela khona (okanye"left"
okanye"right"
).relatedTarget
: Isiqalelo seDOM esityibilikiswa kwindawo njengomba osebenzayo.from
: Isalathiso sento yangokuto
: Isalathiso sento elandelayo
Zonke iziganeko zecarousel zikhutshwa kwicarousel ngokwayo (okt kwi <div class="carousel">
).
Uhlobo loMnyhadala | Inkcazo |
---|---|
isilayidi.bs.carousel | Esi siganeko sitshatyalaliswa ngoko nangoko xa kusenziwa slide indlela yomzekelo. |
slid.bs.carousel | Esi siganeko sigxothwa xa i-carousel igqibile inguqu yayo yesilayidi. |
Guqula ubude bexesha lotshintsho
Ubude bexesha lotshintsho lunokutshintshwa ngokuguquguquka kwe .carousel-item
- $carousel-transition
Sass phambi kokuhlanganiswa okanye izimbo zesiko ukuba usebenzisa i-CSS ehlanganisiweyo. Ukuba iinguqu ezininzi zisetyenziswa, qiniseka ukuba inguqu yenguqu ichazwa kuqala (umz. transition: transform 2s ease, opacity .5s ease-out
).