A t-xaq u´j te Internet o tz´ok t-ximan tjunalx. Qa at jun ti´x mya b´a´n, b´a´n tu´n tok tq´o´n twitza ti´j u´j toj yol inglés.
Tb´anil tajb´en
Q´onxa qe archivos te Gridzy toj t-servidor exttzen q´onxa toj t-xmilala (n-chi b´aj toj t-xaq t-xe´l):
<link rel="stylesheet" href="gridzy/gridzy.min.css" />
<script src="gridzy/gridzy.min.js"></script>Q´onxa aju´ código HTML (noq jaxku tumel toj t-xmilal):
<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>¡Atzun jlu! Atzun jun techlal tz´aqli t-xilen. Mya il ti´j tu´n t-xi tzyet juntl maj.
Tb´inchb´en
A tten mas nya kwest tun t-xi b´inchet Gridzy, noq tu´n tajb´en HTML. Noq o´kx il ti´j tu´n t-xi tq´o´na tnejel kyb´i aye opciones tuk´e data-gridzy- . Iktzun, tun t-xi q´et aju´ t-xilen spaceBetween , noq o´kx t-xi q´et aju´ atributo data-gridzy-spaceBetween .
<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>Aqeju tnejel t-xilen
Justified t-xilen t-xilen
Waterfall t-xilen t-xilen
Mas t-xilen t-xilen
tun t-ximana kyi´j juntl t-xim, q´onka twitza ti´j API .
HTML semántico
A t-xim HTML mas nya kwest te Gridzy atzun jlu:
<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>Noqtzun tu´nj, a Gridzy nimxix t-xilen extzen b´a´n tu´n tajb´en ch´ixmi alkyexku juntl t-xilen HTML. Oʼkx at junjun tiʼchaq tuʼn qximen tiʼj:
- Teyile junjun k´wal te t-xmilal t-xmilal n-chi yek´unte jun tiyjil toj t-xmilal.
- Kykab´il aju´ elemento te tkub´il extzen aye tk´wa´l jaku tz´ok te alkyexku jun t-xilen t-xilen, ikyxjo tze´n
ulexttzenli(noq o´kx b´a´n tu´n t-xi t-ximana tu´n t-xi t-ximana juntl majl t-xilen t-xnaq´tzb´il). - Qa jun elemento
imgmya jun tal k´wal, il ti´j tu´n tten aju clasegridzyImage.
Kyja´tzun, ax ikx jun t-xim HTML n-aq´unan:
<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>Mas qa n-tajb´ena tu´n t-xi tq´o´na junjen t-xaq u´j, il ti´j tu´n tten jun t-xim HTML. tun t-xnaq´tzana mas ti´j, q´onka twitza ti´j Captions & Skins .
Subtítulos & Skins
Qa n-tajb´ena tu´n t-xi tq´o´na junjun t-xaq u´j toj t-galería, il ti´j tu´n t-xi tq´o´na t-xilen t-xilen. Tu´ntzintz, at junjun ky-chib´jel otaq che b´aj b´incha´n. Teyile junjun t-xmilal n-ok te jun archivo CSS. Ilti´j tu´n t-xi tq´o´na aju´ u´j lu´ t-xe´l kye u´j te Gridzy (n-chi b´aj toj t-xaq t-xe´l):
<link rel="stylesheet" href="gridzy/skins/gridzySkinClassic/style.min.css" />Exttzen il ti´j tu´n tten jun t-xim HTML:
<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>Qa n-ximana ti´j t-xim HTML, q´onka twitza ti´j Semantic HTML .
Te t-xilen t-xilen t-xilen t-xilen t-xilen t-xilen, noq o´kx b´a´n tu´n t-xi q´et t-xilen t-xilen gridzyCaption . A t-xilen img ti´j tu´n t-xi t-xnaq´tza´n gridzyImage .
A yek´b´il twitz n-chi tzaj tyek´un teya t-xmilal gridzySkinClassic . tun tajb´en juntl, noq o´kx tz´okx tq´o´na tb´i t-xmilala tuk´e jun kyxol qe jlu:
Skins n-okx toj
| Aqe xnaq´tzb´il at | |
|---|---|
| gridzySkinBlank jun tb´anil t-xe´chil tun t-xi b´inchet jun t-xmilala yek´b´il t-xilen | gridzySkinBlank |
| gridzySkinClassic yek´b´il t-xilen | gridzySkinClassic(DEPRECATED since version 2.6.0) |
| gridzySkinFullOverlay yek´b´il t-xilen | gridzySkinFullOverlay(DEPRECATED since version 2.6.0) |
| gridzySkinLift yek´b´il t-xilen | gridzySkinLift(DEPRECATED since version 2.6.0) |
| gridzySkinMagnifier aju aq´untl te zoom mya n-okx toj yek´b´il t-xilen | gridzySkinMagnifier(DEPRECATED since version 2.6.0) |
Kykyaqil aye t-xmilal twitz tx´otx´ noq n-chi qaninte jun archivo CSS, extzun at junjuntl t-xmilal n-chi qaninte jun archivo JavaScript:
<link rel="stylesheet" href="gridzy/skins/gridzySkinBlur/style.min.css" />
<script src="gridzy/skins/gridzySkinBlur/script.min.js"></script>| Aqe xnaq´tzb´il at | |
|---|---|
| gridzySkinBlur mya n-aq´unan toj IE yek´b´il t-xilen | gridzySkinBlur(DEPRECATED since version 2.6.0) |
| gridzySkinCard yek´b´il t-xilen | gridzySkinCard(DEPRECATED since version 2.6.0) |
Tb´anil t-xmilal
Atxix toj versión 2.6.0 at junjun t-xilen tun t-xi b´inchet aye ky-chib´jel. Ik tza´n t-xilen t-xmilal jaku tz´ok tq´o´na t-xb´alin t-xe´, t-xb´alin u´j ex t-xlekumal u´j. Noq o´kx il ti´j tu´n tajb´en CSS t-xilen t-xilen tza´n t-xi tka´yina tzalu:
<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>Qʼonka twitza kyiʼj qeju variables in che onin ex kyiʼj qeju tajlal in che ajbʼen te junjun skin tzalu:
gridzySkinClassic
| Variable | tajlal tnejel | Tqanil |
|---|---|---|
--background | rgba(0, 0, 0, .7) | n-tzaj tqona junjun t-xilen CSS |
--color | rgb(255, 255, 255) | n-tzaj tqona junjun t-xilen CSS |
--text-shadow | none | n-tzaj tqona jun tajlal CSS text-shadow |
gridzySkinFullOverlay
| Variable | tajlal tnejel | Tqanil |
|---|---|---|
--background | rgba(0, 0, 0, .7) | n-tzaj tqona junjun t-xilen CSS |
--color | rgb(255, 255, 255) | n-tzaj tqona junjun t-xilen CSS |
--text-shadow | none | n-tzaj tqona jun tajlal CSS text-shadow |
gridzySkinLift
| Variable | tajlal tnejel | Tqanil |
|---|---|---|
--background | rgba(0, 0, 0, .7) | n-tzaj tqona junjun t-xilen CSS |
--color | rgb(255, 255, 255) | n-tzaj tqona junjun t-xilen CSS |
--text-shadow | 0 0 10px rgb(0, 0, 0), 0 0 20px rgb(0, 0, 0), 0 0 30px rgb(0, 0, 0) | n-tzaj tqona jun tajlal CSS text-shadow |
gridzySkinMagnifier
| Variable | tajlal tnejel | Tqanil |
|---|---|---|
--background | rgba(0, 0, 0, .7) | n-tzaj tqona junjun t-xilen CSS |
--color | rgb(255, 255, 255) | n-tzaj tqona junjun t-xilen CSS |
A t-xmilal lu mya n-ok t-xnaq´tza´n --text-shadow
gridzySkinBlur
| Variable | tajlal tnejel | Tqanil |
|---|---|---|
--background | rgba(0, 0, 0, .7) | n-tzaj tqona junjun t-xilen CSS |
--color | rgb(255, 255, 255) | n-tzaj tqona junjun t-xilen CSS |
--text-shadow | 0 0 10px rgb(0, 0, 0) | n-tzaj tqona jun tajlal CSS text-shadow |
gridzySkinCard
| Variable | tajlal tnejel | Tqanil |
|---|---|---|
--background | rgba(0, 0, 0, 1) | n-tzaj tqona junjun t-xilen CSS |
--color | rgb(255, 255, 255) | n-tzaj tqona junjun t-xilen CSS |
--text-shadow | none | n-tzaj tqona jun tajlal CSS text-shadow |
Kykyaqil aye skins predefinidos noq n-chi onin kyi´j subtítulos te texto. B´a´n t-ximana tun t-b´inchena t-xmilala extzen t-xmilala mas t-xilen. B´a´n tu´n tok tq´o´n twitza ti´j Style Gridzy .
Style Gridzy
Qa myia jun t-xmilala t-xi t-ximana t-xi t-ximana, b´a´n tu´n t-xi t-ximana t-xmilala.
A tten mas nya kwest a tnejel tu´n t-xi t-sama´na jun t-xmilala ex tu´n t-xi t-ximana ti´j tajb´ila. A t-xmilal gridzySkinBlank n-chi tzaj tqona jun tb´anil t-xe´l extzen jun tb´anil u´j toj u´j CSS:
/** 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;
}Toj u´j CSS n-ok tka´yina aye t-xnaq´tzb´il gridzySkinBlank , gridzyImage exttzen gridzyCaption . A Gridzy mya tajb´en kye xnaq´tzb´il lu. Noq n-ku ajb´en te b´inchb´il extzen tu´n t-xi t-xo´na moqa tu´n t-xi tq´o´na juntl kyb´i qa taja.
Extzun k-okil tka´yina aju´ t-xnaq´tzb´il CSS gridzyItem . A Gridzy n-xi tq´o´n aju´ xnaq´tzb´il lu´ noq tu´nx tib´ kye kykyaqil tk´wal t-xilen aju´ t-xilen t-xilen. Iktzun, b´a´n tu´n tajb´en aju´ xnaq´tzb´il lu´ tun t-xi t-ximana kyi´j ti´chaq te t-galería.
Ximana kyi´j ti´chaq nim kyoklen
- Aju´ t-xilen aju´ ti´chaq il ti´j tu´n t-xi´ t-xnaq´tza´n tkyaqil. Qo ximen ti´j qa aju tajlal elemento ax tok kch´expajel. B´inchama tajlal porcentaje twitz tajlal pixel. extzen q´onka twitza ti´j aju´ t-xilen t-xilen Gridzy
autoFontSize, aju´ n-ok tmojb´a´n t-xilen t-xilen t-xilen t-xilen t-xilen t-xilen. - Teyile junjun tiyjil il ti´j tu´n tten jun t-xilen t-xilen. A t-xilen t-xilen aju´ tiyjil mya n-chi ch´expaj extzen il ti´j tu´n t-xi b´inchet aju´ t-xilen aju´ cuadrícula. Iktzun tten qa jun ti´xti´ mya t-xilen t-xilen t-xilen, b´a´n t-xilen t-xilen t-xilen (se´n css).
Toj junjun amb´il, b´a´n tu´n t-xi b´inchet jun t-xilen t-xilen aye ti´chaq na´mxtoq t-xi tzyet Gridzy. Noq o´kx tz´el tpa´na aju gridzy te xnaq´tzb´il moqa aju archivo javascript te Gridzy noq ch´in amb´il te jlu.
¡Atzun jlu! Noq o´kx jlu il ti´j tu´n t-xi tb´incha´na t-xmilala. Ch´ixme kykyaqil aye t-xmilal predefinidos mya n-chi ajb´en mas twitz jlu.
Extzun jaku tzaj mastl qa tajb´ila ...
Skins avanzados
A Gridzy n-ku tz´ajb´en mas CSS t-xnaq´tzb´il twitz gridzyItem . Ch´ixme kykyaqil n-chi b´aj b´incha´n kyjunalx extzen jaku che ajb´en tu´na tun t-xi b´inchet ky-b´inchb´en.
Clases te contenedores principales
| tb´i xnaq´tzb´il | T-kayb´ajtz |
|---|---|
gridzytun t-xi q´et manualmente | A Gridzy n-chi jyon kyi´j elementos tuk´e aju´ t-xnaq´tzb´il lu extzen n-chi tzaj t-xnaq´tza´n kye. |
gridzyAnimated | Kb´el t-ximan tjunalx qa true aju opción animate . Qa aju´ xnaq´tzb´il lu n-ok q´o´n te q´ob´, aju´ opción animate k-xel t-xi´ true tjunalx (extzun qa ma tz´ok q´o´n te false ). |
xnaq´tzb´il
| tb´i xnaq´tzb´il | T-kayb´ajtz |
|---|---|
gridzyItem | Kb´el q´o´n t-xe t-xilen aju´ tiyjil t-xi tzyet aju´ t-xilen t-xilen. Mlay tz´el q´i´n. |
gridzyItemInitializing | Kb´el q´o´n t-xe t-xilen aju´ tiyjil t-xi tzyet aju´ t-xilen t-xilen. Kxel q´et t-xel gridzyItemReady aj t-xi tzyet tkyaqil t-xilen. Mya t-xilen qa aye tilb´ilal tz´aqliqe (ka´yinxa gridzyItemLoading ), noqtzun aye tiyjil b´antni tun t-xi q´et twitz. |
gridzyItemReady | N-chi tzaj tch´expu´n gridzyItemInitializing noq o´kx aj t-xi tzyet tkyaqil t-xilen. Mlay tz´el q´i´n. Mya t-xilen qa aye tilb´ilal tz´aqliqe (ka´yinxa gridzyItemComplete ), noqtzun aye tiyjil b´antni tun t-xi yek´un. |
gridzyItemLoading | Kb´el q´o´n t-xe t-xilen aju´ tiyjil t-xi tzyet aju´ t-xilen t-xilen. Kxel q´et t-xel tu´n gridzyItemComplete noq o´kx aj t-xi´ t-ximan kyi´j tilb´ilal (o´kx jun). |
gridzyItemComplete | N-chi tzaj tch´expu´n gridzyItemLoading noq o´kx aj t-xi´ t-ximan kyi´j tilb´ilal (o´kx jun) t-xi´ t-ximan. Mlay tz´el q´i´n. |
gridzyItemInitialToVisible | Kb´el b´inchet noq o´kx aj t-xi tzyet tu´n t-xi yek´un aju ti´chaq tnejel maj. K-xel q´i´n t-xe t-xilen t-xilen t-xilen t-xilen. |
gridzyItemVisible | Kb´el q´o´n t-xe t-xilen t-xilen t-xilen t-xilen. K-el q´i´n noq o´kx aj t-xi tzyet tu´n t-xi´ t-xilen aju´ ti´xti´. |
gridzyItemVisibleToHidden | Kb´el b´inchet noq o´kx aj t-xi tzyet tu´n t-xi´ t-xilen aju´ ti´xti´. K-el q´i´n t-xe t-xilen t-xilen t-xilen t-xilen. |
gridzyItemHidden | Kb´el q´o´n t-xe´l t-xi´ t-xmoxin aju´ ti´chaq. K-el q´i´n t-xe´l t-xi tzyet tu´n t-xi yek´un aju´ ti´xti´. |
gridzyItemHiddenToVisible | Kb´el q´o´n t-xe´l t-xi tzyet tu´n t-xi yek´un aju´ tiyjil (extzun t-xi tzyet tu´n t-xi yek´un tnejel maj – q´onka twitza ti´j xnaq´tzb´il gridzyItemInitialToVisible ). K-xel q´i´n t-xe t-xilen t-xilen t-xilen t-xilen. |
gridzyItemVisibleToVisible | Kb´el q´o´n t-xe t-xilen jun ti´x toj t-xaq u´j n-chi ch´expaj, extzun aju´ t-xilen t-xilen ex n-chi b´aj t-ximan. K-xel q´i´n t-xe t-xilen aju´ animación te ch´ixpub´l. |
Noq t-xilen aju´ yek´b´il te b´inchb´en extzen aye animaciones tun t-xi yek´un ex tun t-xi´ naj tilb´ilal n-chi b´aj b´incha´n tu´n aju´ archivo CSS te Gridzy.
tuk´e aye xnaq´tzb´il CSS ma qo yolin ti´j, b´a´n tu´n t-xi t-b´inchena t-ximlal t-ximlal exttzen kye animaciones. B´a´n tu´n toka tka´yina toj u´j CSS te Gridzy, tun t-xi t-ximana ti´chaq k-xel t-ximana. Mi´n tzaj xob´a, tkyaqil b´a´n t-xilen tz´ib´a´n.
B´inchama t-xilen t-xilen
Qa ma tz´ajb´en nim tilb´ilal tu´na, b´a´n tu´n tonina te Gridzy tu´n t-xi t-b´incha aju´ t-xaq t-xaq.
Miʼn che jaw ẍchʼin qe tilbʼilal
A Gridzy ilxix ti´j tu´n t-xi t-ximan aju tajlal t-xilen kykyaqil tilb´ilal tun t-xi t-ximan aju tajlal. Aye tqanil lu n-chi tzaj kyq´o´n junjen elementos saltos qa at junjun tilb´ilal b´antniqe ex junjuntl mya. Qa at nim tilb´ilal, mas tzaj nya b´a´n ti´j aju´ t-xilen lu.
Tun mi´n t-xi´ b´inchet aju´ b´inchb´en lu, noq o´kx q´onxa width ex t- height kye kykyaqil elementos img . Nim toklen tu´n t-xi q´et aju´ tajlal tz´aqli te junjun tilb´ilal, qatzun mya´, aye tilb´ilal n-chi b´aj ky-ximan. Aye tajlal tz´aqli aye tnejel t-xilen ex t-xilen t-xilen junjun tilb´ilal:
<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>Tb´ajlenxi´tzun a Gridzy n-ku tz´ok t-ximan aju´ cuadrícula jun rat naj mya il ti´j tu´n tel tniky´ ti´j t-xilen qe tilb´ilal.
Lazy Loading
tun t-xi t-xo´na noq qe tilb´ilal ate´ toj t-xaq t-xaq, noq o´kx b´inchama qe t-xim lu:
- Q´onk t-xilen
widthexheighttza´n t-xilen twitz (b´a´n tu´n tajb´en qe t-xilen b´a´n) - Q´onk t-xel kykyaqil
srcatributos tuk´edata-gridzylazysrctza´n t-xi yek´un tzalu (qa atsrcsetatributos teya, q´onk t-xel tuk´edata-gridzylazysrcset).
<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>Tej t-xi´ b´inchet aye b´e lu, aye tilb´ilal n-chi b´et t-xe´l t-xe´l t-xe´l extzen t-xe´l t-xe´l t-xilen.
yek´b´il te b´inchb´en
A yek´b´il te b´inchb´en atzun jun tal tilb´ilal n-chi yek´unte aj t-xi q´et tilb´ilal. Qa ma tz´ajb´en subtítulos & skins tu´na, aju yek´b´il te b´inchb´en k-xel yek´un tjunalx. Qa mya´, il ti´j tu´n t-xi b´inchet junjun ch´ixpub´il:
- Q´onxa junjun t-xim
imgtoj jun t-ximdiv
(moqa toj juntl tiyjil – q´onka twitza ti´j HTML semántico tun t-xi tka´yina) - Q´onxa aju´ t-xnaq´tzb´il
gridzyImagetoj junjun elementoimg
<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>Tb´ajlenxi ikyjo, b´a´n tu´n tok tq´o´n twitza kyi´j yek´b´il te b´inchb´en qa aye tilb´ilal n-chi kyi´n amb´il tun t-xi tzyet.
Filtros
Aye filtros toj Gridzy noq ch´in ky-b´inchb´en exttzen at ky-ipumal. Noq alkye tten filtro tajb´ila, b´a´n tu´n t-xi b´inchet. Noq o´kx tajb´ila, jun ch´in CSS ex junjun elementos te formulario HTML ...
Atzun jun techlal aq´untl:
<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>Qo b´inchen junjun t-xaq
1. Tnejel il ti´j tu´n tten aju´ t-xim HTML te Gridzy extzen tu´n t-xi q´et kyb´i kykyaqil t-xim te galería tun t-xi q-b´inchen junjen t-xilen
<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>Toj techel lu noq jun k´loj n-qajb´en te junjun elemento. Pero ax ikx jaku kubʼ tqʼoʼna nimku clase te junx elemento, qa aju elemento lu il tiʼj tuʼn tkanet tuʼn nimku filtro.
2. Yajxitl n-ku q-q´o´n junjun botones tun t-xi q-ch´expu´n aye filtros extzen
<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>Toj t-xel aye botones, b´a´n tu´n tajb´en juntl elementos te u´j tze´nku junjen cuadros, aye botones te radio, aye campos te t-xilen ex txqantl.
Ikytzin t-xi tka´yina, aye tajlal kye botones aye t-xilen CSS. Aj t-xi q-b´inchen, jun t-xilen jun botón ikyjo n-chi yek´unte qe tilb´ilal n-chi ok tmojb´an tib´ tuk´il CSS selector. Tecnicamente noq n-ok tq´o´n aju opción filter te tajlal lu.
Ax ikx jaku tz´ajb´en junjun selectores mas kwest. Jun techel :not(.animals) n-chi aq´unan ax ikx, extzen .animals.people exttzen .animals, .people .
3. Te tmankb´il, n-ku q-okx q´et aye botones toj jun div contenedor extzen n-ku q-ok q-b´inchen toj Gridzy gallery, tun t-xi q-b´inchen aju´ opción filterControls :
<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>Ik tza´n n-ok tka´yina, ax ikx n-qajb´en jun CSS selector te t-xilen filterControls . A div container tuk´e atributo id noq n-ku tz´ajb´en tun t-xi b´inchet aye botones mas nya kwest tu´n t-xi ky-sk´o´n tuk´e aju CSS selector.
¡Atzun jlu!
Qa tajb´ila jun tzaqpib´l te JavaScript, q´onka twitza ti´j API .
API
Maske at jun t-API te Gridzy, nimku tiyjil n-ku b´inchet qa mya at, noq tu´n t-xi t-ximan DOM. A Gridzy k-okil tka´yin extzen k-xel t-ximan aju´ cuadrícula. Extzun at jun API nimxix tipumal ...
N-chi b´inchet aju DOM
Te tkyaqil aq´untl ti´j Document Object Model (DOM) tnejel il ti´j tu´n t-xi q´et aju´ elemento te tkub´il:
// get the container element
var gridzyElement = document.querySelector('.gridzy');Q´onxa tilb´ilal
Nim toklen tu´n t-xi b´inchet ex tu´n t-xi tnojsa´n aju ak´aj elemento tal na´mxtoq t-xi tq´o´na toj elemento te contenedor. Qa mya ikyjo, a Gridzy mya n-ku tz´el tniky´ ti´j t-xilen t-xilen.
// 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);Q´i´nqe tilb´ilal
// remove the first image
gridzyElement.removeChild(gridzyElement.firstElementChild);Ch´expu´nqe t-xim
// 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');Mas ti´j t-xilen DOM n-ku tz´el tniky´a ti´j toj MDN web docs . Ax ikx at jun tnejel xnaq´tzb´il ti´j DOM .
API te t-xilen
Tun tajb´en API, tnejel il ti´j tu´n tten aju´ instancia Gridzy, aju´ n-ok tmojb´an tib´ tuk´il aju´ elemento te tkub´el Gridzy:
// get the Gridzy instance
var gridzyInstance = document.querySelector('.gridzy').gridzy;tz´okx t-ximana
// get the value of a single option
var currentLayout = gridzyInstance.getOption('layout');Tzaj ttzaqpi´na kykyaqil t-xim
// get all option values as an object
var currentOptions = gridzyInstance.getOptions();Q´onk t-xilen
// set specific option values
gridzyInstance.setOptions({
spaceBetween: 10,
layout: 'waterfall'
});
// or reset options to their default values
gridzyInstance.setOptions({
spaceBetween: null,
layout: null
});Q´onxa filtro
Aju´ t-xi q´et jun filtro noq o´kx tu´n t-xi q´et aju´ filter te opción aju´ jaku tz´ok te jun selector CSS b´a´n:
// 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'
});Q´onxa aye aq´untl te Callback
mya b´a´n t-xilen t-xe t -xilen 2.4.0
B´a´n tu´n tajb´en aye eventos ak´aj ex mas flexible te t-xel. Qʼonka twitza tiʼj juntl plaj tuʼn tel tnikʼa tiʼj.
Gridzy.js 2 n-chi tzaj tqona junjun t-xilen tun t-xi b´inchet aq´untl te q´olb´eb´il. Noq o´kx jaku che kub´ q´et toj API te t-xilen, noqtzun aye txqantl tten:
// 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.
}
});B´a´n tu´n tajb´en Eventos
atxix toj versión 2.4.0
B´a´n t-xi t-ximana kyi´j b´ajsb´il Gridzy ikyx tze´nqe b´ajsb´il JavaScript:
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.
});At junjun b´ajsb´il n-chi b´aj t-xo´n tib´aj t-xmilal Gridzy extzen at junjun b´ajsb´il n-chi b´aj t-xo´n tib´aj junjun t-xmilal t-xmilal t-xmilal.
Aye b´ajsb´il n-chi b´et toj t-xmilal Gridzy:
event.target n-tzaj tqona aju t-xilen Gridzy.
event.detail.instance n-tzaj tqona aju Gridzy instance.
Aye b´ajsb´il n-chi b´aj kyi´j elementos:
event.target n-tzaj tqona aju t-xilen t-xilen.
event.detail.instance n-tzaj tqona aju Gridzy instance.
API – Global
At junjun aq´untl mya junx ky-xilen tuk´il Gridzy. kyja´tzun mya il ti´j tu´n t-xi q-k´amo´n jun yek´b´il tnejel.
Tz´okx tq´o´na aju opción default
// get the default value of a single option
var defaultLayout = Gridzy.getDefaultOption('layout');Tz´elx tkyaqil t-xilen t-xilen
// 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');Q´onk t-xilen t-xilen
A jlu mya n-ok tq´o´n ky-b´inchb´en kykyaqil aye instancias Gridzy ya otaq che b´aj b´incha´n, noqtzun aye´ n-ok tq´o´n t-xilen kye ak´aj instancias. Noqtzun tu´nj, qa jun opción te jun instancia atxix ojtxi n-chi b´aj t-ximan juntl majl tuk´e aju´ tajlal null , n-chi ajb´en aju´ ak´aj tajlal t-xe´chil.
// set default option values
Gridzy.setDefaultOptions({
spaceBetween: 10,
layout: 'waterfall'
});B´a´n t-xi t-ximana tun t-xi t-ximana kyi´j t-xim twitz tx´otx´, qa ma txi tq´ama´na na´mxtoq t-xi b´inchet DOM. Iktzun tten mya il ti´j tu´n t-xi tq´o´na junjun opciones te atributos.
Automatismos
Noqtzen kykyaqil aye automatismos te Gridzy.js 2 n-chi aq´unan, mya il ti´j tu´n t-xi b´inchet aye tten lu. Extzun aye automatismos n-ku tz´el kyi´n tun t-xi q´et Gridzy toj jun tten mas t-xilen:
// 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
});Junjun kyxol qeju t-xilen lu mya b´a´n tu´n t-xi q´et toj data-gridzy- atributos moqa toj setOptions() , tu´n tpaj junjun t-xilen:
Tzaj t-xnaq´tza´n t-xnaq´tzb´il
// initialize a new Gridzy instance
var gridzyInstance = new Gridzy(document.querySelector('.gridzy'), {
spaceBetween: 10,
layout: 'waterfall'
});B´aj t-xiten aju´ instancia
Noq ch´in t-xilen, aju´ t-xilen t-xi tzyet Gridzy.
gridzyInstance.destroy();
gridzyInstance = null;Q´onk t-xilen k´wal toj q´ob´
// after child elements (images) are added to or removed from the DOM.
gridzyInstance.syncChildList();Q´onk t-xilen jun elemento te k´wal toj q´ob´
Noq tkyaqil amb´il mya il ti´j, noq o´kx toj junjun amb´il nya nim maj.
// after child elements (images) are added to the DOM and only one of them should be synced to Gridzy.
gridzyInstance.syncChild(childElement);Sincronizar atributos manualmente
Q´onka twitza ti´j qa aju´ useOptionAttributes aju´ t-xilen il ti´j tu´n t-xi´ true .
// after data-gridzy- attributes have changed
gridzyInstance.syncAttributes();Forza Renderización
Noq tkyaqil amb´il mya il ti´j, maske kykyaqil automatismos n-chi kub´ tz´aq
gridzyInstance.render();