Yi luti yusife bara masara a yɛtɛ ra. Xa fe nde mu a ma senxi, wo xa Inglishi xui mato.
A usi singe
Gridzy filee sa wo xa serveur ma a nun wo xa e sa wo xa site ma (a gbegben gni yire xungbe nan kui):
<link rel="stylesheet" href="gridzy/gridzy.min.css" />
<script src="gridzy/gridzy.min.js"></script>Wo HTML kOde sa a fari (a yire birin a fate kui):
<div class="gridzy">
<img src="https://loremflickr.com/640/480?random=1" alt="a random image" />
<img src="https://loremflickr.com/480/640?random=2" alt="another random image" />
<img src="https://loremflickr.com/640/640?random=3" alt="yet another random image" />
<img src="https://loremflickr.com/640/480?random=4" alt="a random image again" />
<img src="https://loremflickr.com/640/480?random=5" alt="one last random image" />
</div>Na nan a ra! Na misali fangni nan a ra. Initialisation gbEtE yo mu lan ma.
Konfigurasiyon
Gridzy rafafe kira mafura nan a ra, wo xa HTML sEbEli nan gbansan yusi. Wo lan ma wo xa sugandi xili sa data-gridzy- nan na. Na kui, ala ko i xa spaceBetween sugandi, i lan ma i xa data-gridzy-spaceBetween sa a fari.
<div class="gridzy" data-gridzy-spaceBetween="20" data-gridzy-desiredHeight="400">
<img src="https://loremflickr.com/640/480?random=1" alt="a random image" />
<img src="https://loremflickr.com/480/640?random=2" alt="another random image" />
<img src="https://loremflickr.com/640/640?random=3" alt="yet another random image" />
<img src="https://loremflickr.com/640/480?random=4" alt="a random image again" />
<img src="https://loremflickr.com/640/480?random=5" alt="one last random image" />
</div>sugandi xungbe
Justified Layout Options
Waterfall Layout Options
Sugandi gbEtE
Xa wo wama fe gbEtE kolon fe, wo API mato.
HTML semantiki
Gridzy xa HTML sEmbE xOrOxOE nan ya:
<div class="gridzy">
<img src="https://loremflickr.com/640/480?random=1" alt="a random image" />
<img src="https://loremflickr.com/480/640?random=2" alt="another random image" />
<img src="https://loremflickr.com/640/640?random=3" alt="yet another random image" />
<img src="https://loremflickr.com/640/480?random=4" alt="a random image again" />
<img src="https://loremflickr.com/640/480?random=5" alt="one last random image" />
</div>Na kui, Gridzy a ma fura a nun wo nOma HTML gbEtE birin yuside. Fe ndee nan gbansan na wo lan wo xa naxee mato:
- Di keren keren ma naxan na konkoe kui a misalixi se keren nan na naxan na grid kui.
- KontinEr element nun a xa die nO ma findi de tag mOli yo ra, alo
ula nunli(wo xa a ma gnOxun wo xa navigateur defaults ra gbilen). - Xa
imgse mu findixi di ra a yEtE ra, a lan ma a xa findigridzyImagera.
Na kui yi fan findixi HTML wali nan na:
<ul class="gridzy">
<li>
<span>
<img class="gridzyImage" src="https://loremflickr.com/640/480?random=1" alt="a random image" />
</span>
</li>
<li>
<span>
<img class="gridzyImage" src="https://loremflickr.com/480/640?random=2" alt="another random image" />
</span>
</li>
<li>
<span>
<img class="gridzyImage" src="https://loremflickr.com/640/640?random=3" alt="yet another random image" />
</span>
</li>
<li>
<span>
<img class="gridzyImage" src="https://loremflickr.com/640/480?random=4" alt="a random image again" />
</span>
</li>
<li>
<span>
<img class="gridzyImage" src="https://loremflickr.com/640/480?random=5" alt="one last random image" />
</span>
</li>
</ul>A gbengben gni wo wama wo xa sEbEli sa a fari, wo lan ma wo xa HTML sEbEli xungbe sOtO. Xa i wama a kolon fe gbEtE, i xa Captions & Skins mato.
Sɛbɛli nun fate
Xa wo wama wo xa sEbEli sa wo xa galeri kui, wo lan ma wo xa a ma sEbE. Na kui, fate ndee na na. Skin keren keren birin na CSS file nan kui. Wo lan ma wo xa yi buki sa Gridzy buki xungbe fari (a wuyaxi ra a xun ma):
<link rel="stylesheet" href="gridzy/skins/gridzySkinClassic/style.min.css" />A nun man wo lan ma wo xa HTML sEmbE sOtO:
<div class="gridzy gridzySkinClassic">
<figure>
<img class="gridzyImage" src="https://loremflickr.com/640/480?random=1" alt="a random image" />
<figcaption class="gridzyCaption">a caption text</figcaption>
</figure>
<figure>
<img class="gridzyImage" src="https://loremflickr.com/480/640?random=2" alt="another random image" />
<figcaption class="gridzyCaption">another caption text</figcaption>
</figure>
<figure>
<img class="gridzyImage" src="https://loremflickr.com/640/640?random=3" alt="yet another random image" />
<figcaption class="gridzyCaption">yet another caption text</figcaption>
</figure>
<figure>
<img class="gridzyImage" src="https://loremflickr.com/640/480?random=4" alt="a random image again" />
<figcaption class="gridzyCaption">a caption text again</figcaption>
</figure>
<figure>
<img class="gridzyImage" src="https://loremflickr.com/640/480?random=5" alt="one last random image" />
<figcaption class="gridzyCaption">one last caption text</figcaption>
</figure>
</div>Xa wo wama wo yEtE maxOrin fe HTML ma, wo Semantic HTML mato.
Na sEbEli ma wo nOma sEbEli mOli birin yusi de, wo xa a kolon a gridzyCaption na a kui. img se lanma a xa findi gridzyImage ra.
Misali naxan na yi bOxi ma a masenxi nE a fate gridzySkinClassic . Xa i wama a gbEtE yusife, i xa a fate xili masara yi keren na:
Skin naxan na a kui
| Kalasi naxan na | |
|---|---|
| gridzySkinBlank a findixi fOlOde fangni nan na wo yEtE xa fate yayilan fe ra fe matofe | gridzySkinBlank |
| gridzySkinClassic fe matofe | gridzySkinClassic(DEPRECATED since version 2.6.0) |
| gridzySkinFullOverlay fe matofe | gridzySkinFullOverlay(DEPRECATED since version 2.6.0) |
| gridzySkinLift fe matofe | gridzySkinLift(DEPRECATED since version 2.6.0) |
| gridzySkinMagnifier zoom wali mu na a kui fe matofe | gridzySkinMagnifier(DEPRECATED since version 2.6.0) |
Yi skin birin CSS file nan gbansan maxOxun ma, kOnO skin gbEtE na JavaScript file nan maxOxun ma:
<link rel="stylesheet" href="gridzy/skins/gridzySkinBlur/style.min.css" />
<script src="gridzy/skins/gridzySkinBlur/script.min.js"></script>| Kalasi naxan na | |
|---|---|
| gridzySkinBlur mu walima IE kui fe matofe | gridzySkinBlur(DEPRECATED since version 2.6.0) |
| gridzySkinCard fe matofe | gridzySkinCard(DEPRECATED since version 2.6.0) |
fate sugandi
Kabi version 2.6.0, sugandi ndee na na wo xa skins kui rafala. A fatanxi fate nan na wo nOma a xanbi ra gningi sade, sEbEli gningi a nun sEbEli dimi. Wo lan ma wo xa CSS nan yusi wo yEtE bE alo wo a toxi ki naxE be:
<div class="gridzy gridzySkinClassic" style="--background: rgba(0, 80, 117, .8); --color: rgb(238, 238, 238); ">
<figure>
<img class="gridzyImage" src="https://loremflickr.com/640/480?random=1" alt="a random image" />
<figcaption class="gridzyCaption">a caption text</figcaption>
</figure>
<figure>
<img class="gridzyImage" src="https://loremflickr.com/480/640?random=2" alt="another random image" />
<figcaption class="gridzyCaption">another caption text</figcaption>
</figure>
...
</div>Wo yi yire mato naxan ma sOtOxi a nun a xasabi naxan na skin keren keren ma:
gridzySkinClassic
| Variable | Valeur default | Ara gbelinfé ma |
|---|---|---|
--background | rgba(0, 0, 0, .7) | a tinma CSS xa sEmbE birin na |
--color | rgb(255, 255, 255) | CSS gningi birin tin ma |
--text-shadow | none | CSS text-shadow value birin tin ma |
gridzySkinFullOverlay
| Variable | Valeur default | Ara gbelinfé ma |
|---|---|---|
--background | rgba(0, 0, 0, .7) | a tinma CSS xa sEmbE birin na |
--color | rgb(255, 255, 255) | CSS gningi birin tin ma |
--text-shadow | none | CSS text-shadow value birin tin ma |
gridzySkinLift
| Variable | Valeur default | Ara gbelinfé ma |
|---|---|---|
--background | rgba(0, 0, 0, .7) | a tinma CSS xa sEmbE birin na |
--color | rgb(255, 255, 255) | CSS gningi birin tin ma |
--text-shadow | 0 0 10px rgb(0, 0, 0), 0 0 20px rgb(0, 0, 0), 0 0 30px rgb(0, 0, 0) | CSS text-shadow value birin tin ma |
gridzySkinMagnifier
| Variable | Valeur default | Ara gbelinfé ma |
|---|---|---|
--background | rgba(0, 0, 0, .7) | a tinma CSS xa sEmbE birin na |
--color | rgb(255, 255, 255) | CSS gningi birin tin ma |
Yi skin mu --text-shadow suxu ma
gridzySkinBlur
| Variable | Valeur default | Ara gbelinfé ma |
|---|---|---|
--background | rgba(0, 0, 0, .7) | a tinma CSS xa sEmbE birin na |
--color | rgb(255, 255, 255) | CSS gningi birin tin ma |
--text-shadow | 0 0 10px rgb(0, 0, 0) | CSS text-shadow value birin tin ma |
gridzySkinCard
| Variable | Valeur default | Ara gbelinfé ma |
|---|---|---|
--background | rgba(0, 0, 0, 1) | a tinma CSS xa sEmbE birin na |
--color | rgb(255, 255, 255) | CSS gningi birin tin ma |
--text-shadow | none | CSS text-shadow value birin tin ma |
Skin birin naxan sugandixi a singe ra a lanma a xa sEbEli gbansan nan na. Wo nOma wo yEtE kan xa fate ma sElExun a nun a xOrOxOE. Wo xa Style Gridzy mato.
Style Gridzy
Xa fate ma sElExun yo mu na wo waxOn gni ma, wo nOma wo yEtE kan xa fate rafalade.
A mafura kira singe nan a ra wo xa skin fori tongo wo xa a findi wo yEtE xayi ra. gridzySkinBlank naxan xili predefined skin a fama nE findi de fondasi fangni ra a nun man sEbEli fangni ra CSS file kui:
/** SKIN Blank **/
/* all gallery items (direct children of the main container element) */
.gridzySkinBlank > .gridzyItem {
overflow: hidden;
}
/* all gallery images (predefined in Gridzy's main CSS file, but can be overridden) */
.gridzySkinBlank .gridzyImage {
}
/* all gallery captions (just create your very own style) */
.gridzySkinBlank .gridzyCaption {
margin: 0;
padding: .5em;
opacity: 0;
display: flex;
justify-content: center;
align-items: center;
text-align: center;
position: absolute;
z-index: 1;
top: 0;
left: 0;
width: 100%;
height: 100%;
box-sizing: border-box;
transition: opacity .5s;
overflow: auto;
background: rgba(0, 0, 0, .7);
color: rgb(255, 255, 255);
}
.gridzySkinBlank > .gridzyItem:hover .gridzyCaption {
opacity: 1;
}CSS file kui wo gridzySkinBlank , gridzyImage a gridzyCaption nan to ma. Gridzy yEtE mu hayi na na xaran gni ma. E lanma e xa rawali styling nan gbansan ma, na nan a ra wo nOma e bade xa na mu wo nOma e xili masarade xa wo wama.
A nun man wo fama CSS sOtOde gridzyItem . Gridzy yi kilasi ra tima a yEtE ra a xa die birin bE naxan na a kui. Na kui, wo nOma yi sariyE uside wo xa galeri see rafafe ra.
Xaxili fe tide na
- Na se kui see lan ma a xa findi yabi ra. Wo xa a ma gnOxun a fe xungbe fama nE masarade. Wo xa percentage nan yusi pixele xOn ma. A nun wo xa Gridzy layout option
autoFontSizemato, naxan font-size xirixi item box size ra. - Se birin lan ma a xa ratio fangni sOtO. Na see xa aspect ratio mu masarama abada a nun a lan ma a xa findi grid xasabi ra. Na kui xa se nde mu a yEtE ra a nun a xa ratio fangni, wo xa a rafala wo yEtE ra (alo css saabui ra).
Waxati n de, a mafura wo xa na se kui see rafala beenun Gridzy xa a fOlO. Wo xa gridzy xa na mu gridzy javascript file ba waxati nde bun ma.
Na nan a ra! Na nan gbansan wo lan ma wo xa wo yEtE kan fate yalan. Skin gbegbe naxan sugandixi a mu dangi yi ra.
KOnO a gbEtE nO ma lude xa wo wama...
fate xungbe
Gridzy CSS wuyaxi nan yusima dangife gridzyItem ra. E gbegbe fama nE rafalade a yEtE ra a nun wo nOma e rawalide wo xa styling fan ma.
Main Container Classes
| Kilasi xili | Anakiènèkhè |
|---|---|
gridzyi xa a rafala i yEtE ra | Gridzy a yEtE ra a yEtE nan fen ma yi kilasi kui a fa e fOlO. |
gridzyAnimated | A fama rafalade a yEtE ra xa animate sugandi findixi true . Xa yi kilasi saxi a yEtE ra, animate sugandi fan fama nE findi de true ra (fo a to findi false ). |
Item Classes
| Kilasi xili | Anakiènèkhè |
|---|---|
gridzyItem | A fama rafalade a fOlOde tEmui na xan ma. A mu fama bade abada. |
gridzyItemInitializing | A fama rafalade a fOlOde tEmui na xan ma. A fama masarade gridzyItemReady ra a to gbata a birin na. A mu a masenxi a fotoe bara rafelen (a mato gridzyItemLoading ), kOnO se bara rafala ala ko a xa to. |
gridzyItemReady | A na gridzyItemInitializing masarama nE a to gbata a birin na. A mu fama bade abada. A mu a masenxi a fotoe bara rafelen (a mato gridzyItemComplete ), kOnO see bara rafala ala ko e xa to. |
gridzyItemLoading | A fama rafalade a fOlOde tEmui na xan ma. A fama masarade gridzyItemComplete nan na, xa na mu a ra, yi pirinti naxan na a kui (a gbengbenyi keren nan a ra) a kamalixi. |
gridzyItemComplete | A fama nE gridzyItemLoading masarade a singe ra (a gbegben gni keren nan) a birin na. A mu fama bade abada. |
gridzyItemInitialToVisible | A fama rafalade a fOlOde a singe ra. A fama nE ba de tEmui na xan ma a to minixi a birin na. |
gridzyItemVisible | A fama rafalade keren na se to minixi a fangni ra. A fama nE ba de a fOlO ma lOE de. |
gridzyItemVisibleToHidden | A fama rafalade tEmui na xan ma se na lOE fOlO ma. A fama bade a ra tEmui na xan ma a nOxunxi. |
gridzyItemHidden | A fama rafalade keren na se nOxunxi tEmui na xan ma. A fama nE ba de a fOlO ma a mini de. |
gridzyItemHiddenToVisible | A fama sade a fOlOde tEmui na xan ma (fo a to mini a singe ra – wo gridzyItemInitialToVisible mato). A fama nE ba de tEmui na xan ma a to minixi a birin na. |
gridzyItemVisibleToVisible | A fama sade tEmui na xan ma se nde masarama, kOnO se yati nan nu na a ra a man luma nE. A fama nE ba de a ra tEmui na xan ma animation masarama. |
A singe ra, wali masen gni a nun animation naxan minixi a nun naxan lOE xi a singe ra Gridzy CSS file nan a ra.
Na CSS xaran gni naxan falaxi a fari wo nOma wo yEtE xa wali masen de a nun animation. Wo xa Gridzy CSS file xungbe mato, ala ko wo xa a faxamu wo lan ma wo xa naxan masara. Wo naxa gaxu, fe birin sEbExi a fangni ra na.
Loading ra fangni
Xa wo foto gbegbe usi, a findima xaxili fangni nan na wo xa Gridzy mali a xa grid rafala mafuren.
Wo naxa fotoe ma goro
Gridzy a lan ma a xa foto birin xa aspect ratio sOtO ala ko a xa grid xasabi kolon. Na fe birin a niyama nE a xa findi fe nde ra naxan ma sOtOxi xa foto ndee bara rafala a nun booree mu bara rafala. Xa misali gbegbe na, na fe nO ma findi de fe xOrOxOE ra.
Xa i wama na fe mOxOyEn fe, i lan ma i xa iyEtE sa a nun i height width img see birin bE. A tide na a ra wo xa sEmbE sa foto keren keren ma, xa na mu fotoe fama nE kanafen de. A lanma a xa findi yi pirinti xa gboe nun a xa gboe ra:
<div class="gridzy">
<img src="https://loremflickr.com/640/480?random=1" width="640" height="480" alt="a random image" />
<img src="https://loremflickr.com/480/640?random=2" width="480" height="640" alt="another random image" />
<img src="https://loremflickr.com/640/640?random=3" width="640" height="640" alt="yet another random image" />
<img src="https://loremflickr.com/640/480?random=4" width="640" height="480" alt="a random image again" />
<img src="https://loremflickr.com/640/480?random=5" width="640" height="480" alt="one last random image" />
</div>Na xanbi Gridzy nOma grid kOde keren na a mu lan a xa a kolon a fotoe xa gboe.
Lazy Loading
Xa i wama fotoe nan gbansan tongofe naxee na yi yire kui, i bira yi kirae fOxOra:
- Wo
widthnunheightsa a kui alo a falaxi ki naxE (wo xa la a ra wo xa a kolon a lanma wo xa naxan yusi) - Wo xa
srcsEmbE birin masaradata-gridzylazysrcra alo a masenxi ki naxan yi ki (xa wosrcsetsEmbE sOtOxi, wo a masaradata-gridzylazysrcsetra).
<div class="gridzy">
<img data-gridzylazysrc="https://loremflickr.com/640/480?random=1" width="640" height="480" alt="a random image" />
<img data-gridzylazysrc="https://loremflickr.com/480/640?random=2" width="480" height="640" alt="another random image" />
<img data-gridzylazysrc="https://loremflickr.com/640/640?random=3" width="640" height="640" alt="yet another random image" />
<img data-gridzylazysrc="https://loremflickr.com/640/480?random=4" width="640" height="480" alt="a random image again" />
<img data-gridzylazysrc="https://loremflickr.com/640/480?random=5" width="640" height="480" alt="one last random image" />
</div>Na walie dangi xanbi, na fotoe fama nE minide e to gbata xa na mu e na viewport kui.
Process Indicator
Process indicator findixi ikone lanma nan na naxan mini ma foto na minife tEmui. Xa wo captions & skins usi, na wali masen gni fama nE minide a yEtE ra. Xa na mu wo lan ma wo xa fe ndee masara:
- Img se
imgsadivse kui
( xa na mu a ra se gbEtE – wo HTML semantiki mato ala ko wo xa a kolon) - Wo xa
gridzyImagesaimgelement keren keren ma
<div class="gridzy">
<div><img src="https://loremflickr.com/640/480?random=1" class="gridzyImage" alt="a random image" /></div>
<div><img src="https://loremflickr.com/480/640?random=2" class="gridzyImage" alt="another random image" /></div>
<div><img src="https://loremflickr.com/640/640?random=3" class="gridzyImage" alt="yet another random image" /></div>
<div><img src="https://loremflickr.com/640/480?random=4" class="gridzyImage" alt="a random image again" /></div>
<div><img src="https://loremflickr.com/640/480?random=5" class="gridzyImage" alt="one last random image" /></div>
</div>Na dangi xanbi wo lan ma wo xa na wali masen gni to xa fotoe waxati tongoxi e xa rafelen.
Filtre
Filtre naxan na gridzy kui a mafura kOnO a sEmbE. A mu lanma wo xa filtre mOdEli sOtO, a lan ma a xa raba. Wo hayi na naxan ma, CSS dondoroti a nun HTML dondoroti nde...
misali fangni nan ya:
<div id="myFilterControls">
<button value="*">All</button>
<button value=".animals">Animals</button>
<button value=".architecture">Architecture</button>
<button value=".people">People</button>
</div>
<div class="gridzy" data-gridzy-filterControls="#myFilterControls button">
<img class="animals" src="https://loremflickr.com/640/480/animals?random=1" alt="a random animal image" />
<img class="architecture" src="https://loremflickr.com/640/480/arch?random=1" alt="a random architecture image" />
<img class="people" src="https://loremflickr.com/640/480/people?random=1" alt="a random people image" />
<img class="animals" src="https://loremflickr.com/640/480/animals?random=2" alt="another random animal image" />
<img class="architecture" src="https://loremflickr.com/640/480/arch?random=2" alt="another random architecture image" />
<img class="people" src="https://loremflickr.com/640/480/people?random=2" alt="another random people image" />
<img class="animals" src="https://loremflickr.com/640/480/animals?random=3" alt="yet another random animal image" />
</div>Won xa a ti sEti keren keren ma
1. A singe won lan ma won xa HTML sEmbE so Gridzy kui a nun won xa classe xili sa galeri see birin ma ala ko won xa nO e ra gbatade na xanbi
<div class="gridzy">
<img class="animals" src="https://loremflickr.com/640/480/animals?random=1" alt="a random animal image" />
<img class="architecture" src="https://loremflickr.com/640/480/arch?random=1" alt="a random architecture image" />
<img class="people" src="https://loremflickr.com/640/480/people?random=1" alt="a random people image" />
<img class="animals" src="https://loremflickr.com/640/480/animals?random=2" alt="another random animal image" />
<img class="architecture" src="https://loremflickr.com/640/480/arch?random=2" alt="another random architecture image" />
<img class="people" src="https://loremflickr.com/640/480/people?random=2" alt="another random people image" />
<img class="animals" src="https://loremflickr.com/640/480/animals?random=3" alt="yet another random animal image" />
</div>Yi misali kui won na kilasi keren nan yusima se keren keren ma. KOnO wo man nOma kilasi wuyaxi sade se keren ma, xa na se lanma a xa to filtre wuyaxi saabui ra.
2. Na xanbi won butOn ndee sa a fari won nOma filtree masarade na xanbi
<button value="*">All</button>
<button value=".animals">Animals</button>
<button value=".architecture">Architecture</button>
<button value=".people">People</button>
<div class="gridzy">
<img class="animals" src="https://loremflickr.com/640/480/animals?random=1" alt="a random animal image" />
<img class="architecture" src="https://loremflickr.com/640/480/arch?random=1" alt="a random architecture image" />
<img class="people" src="https://loremflickr.com/640/480/people?random=1" alt="a random people image" />
<img class="animals" src="https://loremflickr.com/640/480/animals?random=2" alt="another random animal image" />
<img class="architecture" src="https://loremflickr.com/640/480/arch?random=2" alt="another random architecture image" />
<img class="people" src="https://loremflickr.com/640/480/people?random=2" alt="another random people image" />
<img class="animals" src="https://loremflickr.com/640/480/animals?random=3" alt="yet another random animal image" />
</div>Na butOn ma, wo nOma formE gbEtE nan yusi de alo kObiri, radiyo butOn, yire sugandi a nun na maniE.
Alo wo a toxi ki naxE, butOn gbegbe nan na CSS sugandixie ra. Won na gEgEn, wo na butOn din wo xa na fotoe masen wo bE naxan na CSS sugandixi ra. A lanma a xa filter option sa yi wali nan ma.
Wo man nOma sugandi gbEtEe rawalide. Misali ra :not(.animals) fan walima, a nun .animals.people a nun .animals, .people .
3. A dOnxE ra, moxo na butOn ndee sa div kui moxo e raso Gridzy galeri kui, moxo na filterControls sugandi:
<div id="myFilterControls">
<button value="*">All</button>
<button value=".animals">Animals</button>
<button value=".architecture">Architecture</button>
<button value=".people">People</button>
</div>
<div class="gridzy" data-gridzy-filterControls="#myFilterControls button">
<img class="animals" src="https://loremflickr.com/640/480/animals?random=1" alt="a random animal image" />
<img class="architecture" src="https://loremflickr.com/640/480/arch?random=1" alt="a random architecture image" />
<img class="people" src="https://loremflickr.com/640/480/people?random=1" alt="a random people image" />
<img class="animals" src="https://loremflickr.com/640/480/animals?random=2" alt="another random animal image" />
<img class="architecture" src="https://loremflickr.com/640/480/arch?random=2" alt="another random architecture image" />
<img class="people" src="https://loremflickr.com/640/480/people?random=2" alt="another random people image" />
<img class="animals" src="https://loremflickr.com/640/480/animals?random=3" alt="yet another random animal image" />
</div>Wo a toxi nE, moxo man CSS sugandixi nan yusima filterControls sugandi fe ra. div kOntEr naxan na id attribute ra a gbansan nan a niyama butOn sugandife xa mafura na CSS sugandixi saabui ra.
Na nan a ra!
Xa wo wama JavaScript nan xOn, wo API mato.
API
Hali Gridzy to a yEtE kan API sOtOxi, fe gbegbe nOma rabade a mu na, DOM nan gbansan na. Gridzy a kolon ma nE a fa grid rafala. KOnO API sEmbE fan na ...
DOM ma sEmbE sofe
Document Object Model (DOM) maniyE birin ma won lan ma won xa container element nan tongo:
// get the container element
var gridzyElement = document.querySelector('.gridzy');Wo xa fotoe sa a fari
A tide na a ra wo xa dimEdi nEnE rafala a nun wo xa a rafe beenun wo xa a sa kontiErE kui. Xa na mu Gridzy mu nOma a xa gboe kolon de.
// create a new img element
var newImage = document.createElement('img');
// add src attribute (!! before you add it to the container element !!)
newImage.src = 'https://loremflickr.com/640/480';
// add it as last element to the container element
gridzyElement.appendChild(newImage);
// or as first element (or anywhere in between)
gridzyElement.insertBefore(newImage, gridzyElement.firstChild);Wo xa fotoe ba
// remove the first image
gridzyElement.removeChild(gridzyElement.firstElementChild);Sugandi masarama
// change the spaceBetween option to a specific value
gridzyElement.setAttribute('data-gridzy-spaceBetween', '10');
// change the layout option to a specific value
gridzyElement.setAttribute('data-gridzy-layout', 'waterfall');
// reset the spaceBetween option to its default value
gridzyElement.removeAttribute('data-gridzy-spaceBetween');Wo nOma DOM ma sEmbE so de wo nOma a tode MDN web docs . DOM xa fe singe fan na.
API yEtE kan
Xa i wama API usi fe, i lan ma i xa Gridzy misali singe nan tongo, naxan na Gridzy ma sEmbE ra:
// get the Gridzy instance
var gridzyInstance = document.querySelector('.gridzy').gridzy;sugandi sOtO
// get the value of a single option
var currentLayout = gridzyInstance.getOption('layout');sugandi birin sOtO
// get all option values as an object
var currentOptions = gridzyInstance.getOptions();sugandi sugandi
// set specific option values
gridzyInstance.setOptions({
spaceBetween: 10,
layout: 'waterfall'
});
// or reset options to their default values
gridzyInstance.setOptions({
spaceBetween: null,
layout: null
});Filtre sa fe
Filtre sa fe nan na option filter na naxan nO ma findi de CSS sugandixi ra:
// set the filter to match items with class "animals"
gridzyInstance.setOptions({
filter: '.animals'
});
// reset the filter to match all items again
gridzyInstance.setOptions({
filter: '*'
});
// set the filter to match items without class "animals"
gridzyInstance.setOptions({
filter: ':not(.animals)'
});
// set the filter to match items with class "animals" or "people"
gridzyInstance.setOptions({
filter: '.animals, .people'
});
// set the filter to match items that have both classes, "animals" and "people"
gridzyInstance.setOptions({
filter: '.animals.people'
});Callback walie sa a fari
A bara kana kabi version 2.4.0
Wo yi waxati nun fe nEnEe yusi. Wo yi yire mato ala ko wo xa a kolon.
Gridzy.js 2 a yi ra sEmbE so ma nE a xili ma. E nOma sade API nan gbansan ma, kOnO alo sugandi gbEtE:
// same as set other options
gridzyInstance.setOptions({
onOptionsChanged: function() {
// will be executed each time the options have changed.
},
onBeforeOptionsChanged: function() {
// will be executed, before new options take effect.
}
});Events usi
kelife 2.4.0
Wo nOma Gridzy fe raba de alo JavaScript fe raba ki:
document.addEventListener('gridzyOptionsChanged', function(event) {
// will be executed each time the options have changed.
});
document.addEventListener('gridzyBeforeOptionsChanged', function(event) {
// will be executed, before new options take effect.
});Fe ndee na gridzy ma naxan na a kui a nun fe gbEtE naxan na a kui.
Fe naxan nabaxi Gridzy konti kui:
event.target na gridzy sEmbE fima.
event.detail.instance Gridzy misali fima.
Fe naxan nabaxi se nde ma:
event.target na se nde nan fima.
event.detail.instance na Gridzy misali nan fima.
API – Global
Wali ndee na na naxee mu fatanxi Gridzy ra. Na kui won mu lan ma won xa misali nde sOtO sinden.
Default Option sOtO
// get the default value of a single option
var defaultLayout = Gridzy.getDefaultOption('layout');Wo xa sugandi birin sOtO
// get all default option values as an object, including the default layout options of the default layout
var defaultOptions = Gridzy.getDefaultOptions();
// or get all default option values, including the default layout options of a specific layout
var defaultOptions = Gridzy.getDefaultOptions('waterfall');Sugandi singe sa
Na mu Gridzy misalie birin sugandi ma, kOnO misali nEnEe nan ma senxi. Na kui, xa a sa li option naxan na instance fori kui a fama nE gbilen de a ra null , a fama nE default value nEnE nan yusi de.
// set default option values
Gridzy.setDefaultOptions({
spaceBetween: 10,
layout: 'waterfall'
});Wo nOma yi rawalide ala ko wo xa option sa duniE birin ma, xa wo a xili beenun DOM xa rafala. Na kui wo mu lan ma wo xa optione sa alo attribute sOnOn.
Automatisms
Xa a sa li Gridzy.js 2 xa automatisme birin na walife, a mu lanma a xa yi walie raba. KOnO automatisme nO ma kana de ala ko a xa Gridzy usi kira fori ra:
// disable automatic initializations
Gridzy.setDefaultOptions({
autoInitOnDomReady: false,
autoInitOnDomMutation: false
});
// or switch off all mutation observers
Gridzy.setDefaultOptions({
autoInitOnDomMutation: false,
autoSyncChildListMutation: false,
autoSyncAttributesMutation: false,
autoSyncChildClassMutation: false,
autoSyncImageMutation: false
});Na sugandi ndee mu nOma sade data-gridzy- atributes saabui ra xa na mu setOptions() saabui ra, barima a lanma:
Wo a fOlO wo yEtE ra
// initialize a new Gridzy instance
var gridzyInstance = new Gridzy(document.querySelector('.gridzy'), {
spaceBetween: 10,
layout: 'waterfall'
});Wo xa na misali kana
A falafe ra, a nun Gridzy fOlOde.
gridzyInstance.destroy();
gridzyInstance = null;DimEdie xili sEbE fe wo yEtE ra
// after child elements (images) are added to or removed from the DOM.
gridzyInstance.syncChildList();Di keren xa fe ra sEmbE sofe i yEtE ra
A wuyaxi ra a mu lan ma, fo waxati nde.
// after child elements (images) are added to the DOM and only one of them should be synced to Gridzy.
gridzyInstance.syncChild(childElement);Sync attributes manuelly
Wo a kolon a useOptionAttributes lanma a xa findi true yi fe ma.
// after data-gridzy- attributes have changed
gridzyInstance.syncAttributes();Force Rendering
A wuyaxi ra a mu lan ma, hali automatisme birin na ganxi
gridzyInstance.render();