ເວັບໄຊທ໌ໄດ້ຖືກແປໂດຍອັດຕະໂນມັດ. ຖ້າມີບາງຢ່າງບໍ່ຊັດເຈນ, ກະລຸນາເບິ່ງເອກະສານພາສາອັງກິດ.
ການນໍາໃຊ້ພື້ນຖານ
ອັບໂຫລດໄຟລ໌ Gridzy ກັບເຄື່ອງແມ່ຂ່າຍຂອງທ່ານແລະເພີ່ມພວກມັນໃສ່ເວັບໄຊທ໌ຂອງທ່ານ (ໂດຍປົກກະຕິຢູ່ໃນສ່ວນຫົວ):
<link rel="stylesheet" href="gridzy/gridzy.min.css" />
<script src="gridzy/gridzy.min.js"></script>ເພີ່ມລະຫັດ HTML (ບ່ອນໃດກໍໄດ້ໃນສ່ວນເນື້ອໃນ):
<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>ນັ້ນເອງ! ນັ້ນແມ່ນຕົວຢ່າງທີ່ມີປະໂຫຍດຢ່າງເຕັມທີ່. ບໍ່ຈໍາເປັນຕ້ອງມີການເລີ່ມຕົ້ນເພີ່ມເຕີມ.
ການຕັ້ງຄ່າ
ວິທີທີ່ງ່າຍທີ່ສຸດໃນການຕັ້ງຄ່າ Gridzy ແມ່ນ, ພຽງແຕ່ໃຊ້ຄຸນລັກສະນະ HTML. ທ່ານພຽງແຕ່ຕ້ອງການນໍາຫນ້າຊື່ທາງເລືອກທີ່ມີ data-gridzy- . ດັ່ງນັ້ນ, ເພື່ອກໍານົດທາງເລືອກ spaceBetween , ພຽງແຕ່ເພີ່ມ attribute 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>ຕົວເລືອກຫຼັກ
Justified ຕົວເລືອກໂຄງຮ່າງ
Waterfall ຕົວເລືອກການຈັດວາງ
ຕົວເລືອກຂັ້ນສູງເພີ່ມເຕີມ
ສໍາລັບທາງເລືອກຂັ້ນສູງ, ກວດເບິ່ງ API .
HTML ຄວາມຫມາຍ
ໂຄງສ້າງ HTML ທີ່ງ່າຍດາຍທີ່ສຸດຂອງ Gridzy ແມ່ນນີ້:
<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>ຢ່າງໃດກໍຕາມ, Gridzy ມີຄວາມຍືດຫຍຸ່ນຫຼາຍແລະທ່ານສາມາດນໍາໃຊ້ເກືອບທຸກໂຄງສ້າງ HTML ອື່ນໆ. ມີພຽງແຕ່ບາງຈຸດທີ່ຈະພິຈາລະນາ:
- ແຕ່ລະລູກຂອງອົງປະກອບບັນຈຸເປັນຕົວແທນຫນຶ່ງລາຍການໃນຕາຂ່າຍໄຟຟ້າ.
- ທັງອົງປະກອບບັນຈຸແລະລູກຂອງມັນສາມາດເປັນປະເພດໂຄດຄໍາສັ່ງໃດໆ, ເຊັ່ນ
ulແລະli(ພຽງແຕ່ພິຈາລະນາທີ່ຈະປັບຄ່າເລີ່ມຕົ້ນຂອງຕົວທ່ອງເວັບ). - ຖ້າອົງປະກອບ
imgບໍ່ແມ່ນລູກໂດຍກົງ, ມັນຕ້ອງການ classgridzyImage.
ດັ່ງນັ້ນ, ນີ້ແມ່ນໂຄງສ້າງ HTML ທີ່ເຮັດວຽກ:
<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>ໂດຍສະເພາະຖ້າທ່ານຕ້ອງການເພີ່ມຄໍາບັນຍາຍ, ທ່ານຕ້ອງການໂຄງສ້າງ HTML ຂັ້ນສູງ. ເພື່ອສຶກສາເພີ່ມເຕີມກ່ຽວກັບມັນ, ກະລຸນາເບິ່ງທີ່ Captions & Skins .
ຄຳບັນຍາຍ ແລະຜິວໜັງ
ຖ້າທ່ານຕ້ອງການເພີ່ມຄໍາບັນຍາຍໃສ່ຄັງຮູບພາບຂອງທ່ານ, ທ່ານຈໍາເປັນຕ້ອງກໍານົດຮູບລັກສະນະ. ດັ່ງນັ້ນ, ບາງຜິວຫນັງທີ່ກໍານົດໄວ້ລ່ວງຫນ້າແມ່ນມີຢູ່. ແຕ່ລະຜິວປະກອບດ້ວຍໄຟລ໌ CSS. ທ່ານຈໍາເປັນຕ້ອງເພີ່ມໄຟລ໌ນີ້ ນອກເຫນືອໄປ ຈາກໄຟລ໌ Gridzy ຕົ້ນຕໍ (ປົກກະຕິແລ້ວຢູ່ໃນສ່ວນຫົວ):
<link rel="stylesheet" href="gridzy/skins/gridzySkinClassic/style.min.css" />ນອກຈາກນັ້ນ, ທ່ານຕ້ອງການໂຄງສ້າງ 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>ຖ້າທ່ານສົງໄສກ່ຽວກັບໂຄງສ້າງ HTML, ເບິ່ງ Semantic HTML .
ສໍາລັບຄໍາບັນຍາຍທີ່ທ່ານສາມາດນໍາໃຊ້ແທັກປະເພດໃດກໍ່ຕາມ, ພຽງແຕ່ໃຫ້ແນ່ໃຈວ່າມັນມີລະດັບ gridzyCaption . ອົງປະກອບ img ຕ້ອງການ class gridzyImage .
ຕົວຢ່າງຂ້າງເທິງສະແດງໃຫ້ທ່ານເຫັນຜິວຫນັງ gridzySkinClassic . ເພື່ອໃຊ້ອັນອື່ນ, ພຽງແຕ່ປ່ຽນຊື່ຜິວດ້ວຍອັນໃດອັນໜຶ່ງເຫຼົ່ານີ້:
ລວມມີ Skins
| ຫ້ອງຮຽນທີ່ມີຢູ່ | |
|---|---|
| gridzySkinBlank ຈຸດເລີ່ມຕົ້ນທີ່ດີສໍາລັບການສ້າງຜິວຫນັງຂອງຕົນເອງ ຕົວຢ່າງສົດ | gridzySkinBlank |
| gridzySkinClassic ຕົວຢ່າງສົດ | gridzySkinClassic(ຖືກຍົກເລີກຕັ້ງແຕ່ເວີຊັນ 2.6.0) |
| gridzySkinFullOverlay ຕົວຢ່າງສົດ | gridzySkinFullOverlay(ຖືກຍົກເລີກຕັ້ງແຕ່ເວີຊັນ 2.6.0) |
| gridzySkinLift ຕົວຢ່າງສົດ | gridzySkinLift(ຖືກຍົກເລີກຕັ້ງແຕ່ເວີຊັນ 2.6.0) |
| gridzySkinMagnifier ຟັງຊັນຊູມບໍ່ໄດ້ລວມ ຕົວຢ່າງສົດ | gridzySkinMagnifier(ຖືກຍົກເລີກຕັ້ງແຕ່ເວີຊັນ 2.6.0) |
ຜິວຫນັງຂ້າງເທິງທັງຫມົດຕ້ອງການໄຟລ໌ CSS, ແຕ່ມີ skins ເພີ່ມເຕີມທີ່ຕ້ອງການໄຟລ໌ JavaScript:
<link rel="stylesheet" href="gridzy/skins/gridzySkinBlur/style.min.css" />
<script src="gridzy/skins/gridzySkinBlur/script.min.js"></script>| ຫ້ອງຮຽນທີ່ມີຢູ່ | |
|---|---|
| gridzySkinBlur ບໍ່ໄດ້ເຮັດວຽກຢູ່ໃນ IE ຕົວຢ່າງສົດ | gridzySkinBlur(ຖືກຍົກເລີກຕັ້ງແຕ່ເວີຊັນ 2.6.0) |
| gridzySkinCard ຕົວຢ່າງສົດ | gridzySkinCard(ຖືກຍົກເລີກຕັ້ງແຕ່ເວີຊັນ 2.6.0) |
ຕົວເລືອກຜິວຫນັງ
ຕັ້ງແຕ່ສະບັບ 2.6.0 ມີທາງເລືອກໃນການກໍານົດຄ່າສະກິນໃນຕົວ. ອີງຕາມຜິວຫນັງສະເພາະ, ທ່ານສາມາດກໍານົດສີພື້ນຫລັງ, ສີຂໍ້ຄວາມແລະເງົາຂໍ້ຄວາມ. ທ່ານພຽງແຕ່ຕ້ອງໃຊ້ຄຸນສົມບັດທີ່ກໍາຫນົດເອງ CSS ຕາມທີ່ທ່ານສາມາດເບິ່ງໄດ້ທີ່ນີ້:
<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>ກວດເບິ່ງຕົວແປທີ່ສະຫນັບສະຫນູນແລະຄ່າເລີ່ມຕົ້ນສໍາລັບແຕ່ລະຜິວຫນັງຢູ່ທີ່ນີ້:
gridzySkinClassic
| ຕົວແປ | ຄ່າເລີ່ມຕົ້ນ | ຂໍ້ມູນ |
|---|---|---|
--background | rgba(0, 0, 0, .7) | ອະນຸຍາດໃຫ້ ມີຄ່າພື້ນຫຼັງ CSS ໃດໆ |
--color | rgb(255, 255, 255) | ອະນຸຍາດໃຫ້ ຄ່າສີ CSS ໃດໆ |
--text-shadow | none | ອະນຸຍາດໃຫ້ ຄ່າ CSS text-shadow ໃດໆ |
gridzySkinFullOverlay
| ຕົວແປ | ຄ່າເລີ່ມຕົ້ນ | ຂໍ້ມູນ |
|---|---|---|
--background | rgba(0, 0, 0, .7) | ອະນຸຍາດໃຫ້ ມີຄ່າພື້ນຫຼັງ CSS ໃດໆ |
--color | rgb(255, 255, 255) | ອະນຸຍາດໃຫ້ ຄ່າສີ CSS ໃດໆ |
--text-shadow | none | ອະນຸຍາດໃຫ້ ຄ່າ CSS text-shadow ໃດໆ |
gridzySkinLift
| ຕົວແປ | ຄ່າເລີ່ມຕົ້ນ | ຂໍ້ມູນ |
|---|---|---|
--background | rgba(0, 0, 0, .7) | ອະນຸຍາດໃຫ້ ມີຄ່າພື້ນຫຼັງ CSS ໃດໆ |
--color | rgb(255, 255, 255) | ອະນຸຍາດໃຫ້ ຄ່າສີ CSS ໃດໆ |
--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 ໃດໆ |
gridzySkinMagnifier
| ຕົວແປ | ຄ່າເລີ່ມຕົ້ນ | ຂໍ້ມູນ |
|---|---|---|
--background | rgba(0, 0, 0, .7) | ອະນຸຍາດໃຫ້ ມີຄ່າພື້ນຫຼັງ CSS ໃດໆ |
--color | rgb(255, 255, 255) | ອະນຸຍາດໃຫ້ ຄ່າສີ CSS ໃດໆ |
ຜິວໜັງນີ້ບໍ່ຮອງຮັບ --text-shadow
gridzySkinBlur
| ຕົວແປ | ຄ່າເລີ່ມຕົ້ນ | ຂໍ້ມູນ |
|---|---|---|
--background | rgba(0, 0, 0, .7) | ອະນຸຍາດໃຫ້ ມີຄ່າພື້ນຫຼັງ CSS ໃດໆ |
--color | rgb(255, 255, 255) | ອະນຸຍາດໃຫ້ ຄ່າສີ CSS ໃດໆ |
--text-shadow | 0 0 10px rgb(0, 0, 0) | ອະນຸຍາດໃຫ້ ຄ່າ CSS text-shadow ໃດໆ |
gridzySkinCard
| ຕົວແປ | ຄ່າເລີ່ມຕົ້ນ | ຂໍ້ມູນ |
|---|---|---|
--background | rgba(0, 0, 0, 1) | ອະນຸຍາດໃຫ້ ມີຄ່າພື້ນຫຼັງ CSS ໃດໆ |
--color | rgb(255, 255, 255) | ອະນຸຍາດໃຫ້ ຄ່າສີ CSS ໃດໆ |
--text-shadow | none | ອະນຸຍາດໃຫ້ ຄ່າ CSS text-shadow ໃດໆ |
ຜິວໜັງທີ່ກຳນົດໄວ້ລ່ວງໜ້າທັງໝົດຮອງຮັບການໃສ່ຄຳບັນຍາຍແບບງ່າຍໆເທົ່ານັ້ນ. ທ່ານສາມາດສ້າງຜິວຫນັງຂອງທ່ານເອງແລະສະລັບສັບຊ້ອນຫຼາຍ. ກະລຸນາເບິ່ງທີ່ Style Gridzy .
ແບບ Gridzy
ຖ້າບໍ່ມີຜິວໜັງທີ່ກຳນົດໄວ້ລ່ວງໜ້າ ເໝາະກັບຄວາມຕ້ອງການຂອງເຈົ້າ, ເຈົ້າສາມາດແຕ່ງຕົວເຈົ້າເອງໄດ້.
ວິທີທີ່ງ່າຍທີ່ສຸດແມ່ນທໍາອິດຄັດລອກຜິວຫນັງທີ່ມີຢູ່ແລ້ວແລະດັດແປງມັນໃຫ້ເຫມາະສົມກັບຄວາມຕ້ອງການຂອງທ່ານເອງ. gridzySkinBlank ຜິວໜັງທີ່ກຳນົດໄວ້ລ່ວງໜ້າໂດຍປົກກະຕິຈະໃຫ້ພື້ນຖານທີ່ດີພ້ອມທັງເອກະສານທີ່ດີໃນໄຟລ໌ 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;
}ໃນໄຟລ໌ CSS ທ່ານຈະພົບເຫັນຫ້ອງຮຽນ gridzySkinBlank , gridzyImage ແລະ gridzyCaption . Gridzy ຕົນເອງບໍ່ຕ້ອງການຫ້ອງຮຽນເຫຼົ່ານີ້. ພວກມັນຖືກນໍາໃຊ້ພຽງແຕ່ສໍາລັບການຄໍເຕົ້າໄຂ່ທີ່ແລະດັ່ງນັ້ນທ່ານສາມາດເອົາອອກຫຼືປ່ຽນຊື່ພວກເຂົາຖ້າທ່ານຕ້ອງການ.
ນອກຈາກນັ້ນ, ທ່ານຈະຊອກຫາ CSS class gridzyItem . Gridzy ກໍານົດຫ້ອງຮຽນນີ້ອັດຕະໂນມັດໃຫ້ກັບເດັກນ້ອຍໂດຍກົງທັງຫມົດຂອງອົງປະກອບບັນຈຸຕົ້ນຕໍ. ດັ່ງນັ້ນ, ທ່ານສາມາດນໍາໃຊ້ຫ້ອງຮຽນນີ້ເພື່ອຈັດຮູບແບບລາຍການຂອງຄັງຂອງເຈົ້າ.
ສິ່ງທີ່ສໍາຄັນຂອງຈິດໃຈ
- ເນື້ອໃນລາຍການຄວນຈະຕອບສະຫນອງຢ່າງເຕັມສ່ວນ. ພິຈາລະນາວ່າຂະຫນາດອົງປະກອບຈະປ່ຽນແປງແນ່ນອນ. ໃຊ້ຄ່າເປີເຊັນແທນຄ່າ pixels. ແລະເບິ່ງຕົວເລືອກຮູບແບບ Gridzy
autoFontSize, ເຊິ່ງຜູກມັດຂະຫນາດຕົວອັກສອນໃສ່ກັບຂະຫນາດກ່ອງລາຍການ. - ແຕ່ລະລາຍການຄວນມີອັດຕາສ່ວນທີ່ກຳນົດໄວ້ໄດ້ດີ. ອັດຕາສ່ວນຂອງລາຍການຈະບໍ່ປ່ຽນແປງ ແລະມີຄວາມຈໍາເປັນໃນການຄິດໄລ່ຕາໜ່າງ. ດັ່ງນັ້ນ, ຖ້າລາຍການບໍ່ມີອັດຕາສ່ວນລັກສະນະທີ່ຖືກກໍານົດໄວ້ດີໂດຍອັດຕະໂນມັດ, ໃຫ້ກໍານົດມັນດ້ວຍຕົນເອງ (ເຊັ່ນ: ຜ່ານ css).
ໃນບາງກໍລະນີ, ມັນອາດຈະງ່າຍກວ່າທີ່ຈະຈັດຮູບແບບເນື້ອຫາຂອງລາຍການກ່ອນທີ່ Gridzy ຈະເລີ່ມຕົ້ນ. ພຽງແຕ່ເອົາ class gridzy ຫຼືໄຟລ໌ Gridzy javascript ຊົ່ວຄາວສໍາລັບການນີ້.
ນັ້ນເອງ! ນັ້ນແມ່ນທັງຫມົດທີ່ທ່ານຕ້ອງການເພື່ອສ້າງຜິວຫນັງຂອງທ່ານເອງ. ຜິວໜັງສ່ວນໃຫຍ່ທີ່ໄດ້ກຳນົດໄວ້ລ່ວງໜ້າບໍ່ໄດ້ໃຊ້ຫຼາຍກວ່ານີ້.
ແຕ່ອາດຈະມີຫຼາຍກວ່າຖ້າຫາກວ່າທ່ານຕ້ອງການ ...
ຜິວໜັງຂັ້ນສູງ
Gridzy ໃຊ້ຫ້ອງຮຽນ CSS ຫຼາຍກ່ວາພຽງແຕ່ gridzyItem . ພວກມັນສ່ວນໃຫຍ່ຈະຖືກຕັ້ງຄ່າໂດຍອັດຕະໂນມັດ ແລະທ່ານສາມາດໃຊ້ພວກມັນເພື່ອຈັດຄໍເຕົ້າໄຂ່ທີ່ຄືກັນ.
ຫ້ອງຮຽນຕູ້ຄອນເທນເນີຫຼັກ
| ຊື່ຫ້ອງຮຽນ | ລາຍລະອຽດ |
|---|---|
gridzyເພື່ອຕັ້ງດ້ວຍຕົນເອງ | Gridzy ຊອກຫາອົງປະກອບທີ່ມີຫ້ອງຮຽນນີ້ໂດຍອັດຕະໂນມັດແລະເລີ່ມຕົ້ນພວກມັນ. |
gridzyAnimated | ຈະຖືກຕັ້ງໂດຍອັດຕະໂນມັດຖ້າຕົວເລືອກ animate ເປັນ true . ຖ້າຫ້ອງຮຽນນີ້ຖືກຕັ້ງດ້ວຍຕົນເອງ, ຕົວເລືອກ animate ຈະເປັນ true ໂດຍອັດຕະໂນມັດ (ຍົກເວັ້ນຖ້າມັນຖືກຕັ້ງເປັນ false ຢ່າງຈະແຈ້ງ). |
ປະເພດລາຍການ
| ຊື່ຫ້ອງຮຽນ | ລາຍລະອຽດ |
|---|---|
gridzyItem | ຈະຖືກກໍານົດທັນທີທີ່ລາຍການເລີ່ມຕົ້ນຂະບວນການເລີ່ມຕົ້ນ. ຈະບໍ່ຖືກໂຍກຍ້າຍ. |
gridzyItemInitializing | ຈະຖືກກໍານົດທັນທີທີ່ລາຍການເລີ່ມຕົ້ນຂະບວນການເລີ່ມຕົ້ນ. ຈະຖືກແທນທີ່ດ້ວຍ gridzyItemReady ທັນທີທີ່ລາຍການໄດ້ຖືກເລີ່ມຕົ້ນຢ່າງເຕັມສ່ວນ. ບໍ່ໄດ້ໝາຍຄວາມວ່າຮູບພາບຖືກໂຫຼດເຕັມແລ້ວ (ເບິ່ງ gridzyItemLoading ), ແຕ່ລາຍການແມ່ນພ້ອມທີ່ຈະເຫັນໄດ້. |
gridzyItemReady | ຈະປ່ຽນແທນ gridzyItemInitializing ທັນທີທີ່ລາຍການໄດ້ຖືກເລີ່ມຕົ້ນຢ່າງເຕັມສ່ວນ. ຈະບໍ່ຖືກໂຍກຍ້າຍ. ບໍ່ໄດ້ໝາຍຄວາມວ່າຮູບພາບຖືກໂຫຼດເຕັມແລ້ວ (ເບິ່ງ gridzyItemComplete ), ແຕ່ລາຍການແມ່ນພ້ອມທີ່ຈະເຫັນໄດ້. |
gridzyItemLoading | ຈະຖືກກໍານົດທັນທີທີ່ລາຍການເລີ່ມຕົ້ນຂະບວນການເລີ່ມຕົ້ນ. ຈະຖືກແທນທີ່ດ້ວຍ gridzyItemComplete ທັນທີທີ່ຮູບພາບທີ່ມີ (ປົກກະຕິແລ້ວມີພຽງອັນດຽວ) ຖືກໂຫລດເຕັມ. |
gridzyItemComplete | ຈະປ່ຽນແທນ gridzyItemLoading ທັນທີທີ່ຮູບພາບທີ່ມີ (ປົກກະຕິແລ້ວມີພຽງອັນດຽວ) ຖືກໂຫລດເຕັມ. ຈະບໍ່ຖືກໂຍກຍ້າຍ. |
gridzyItemInitialToVisible | ຈະຖືກຕັ້ງທັນທີທີ່ລາຍການເລີ່ມປາກົດເປັນຄັ້ງທຳອິດ. ຈະຖືກເອົາອອກທັນທີທີ່ລາຍການເຫັນໄດ້ຢ່າງສົມບູນ. |
gridzyItemVisible | ຈະຖືກຕັ້ງທັນທີທີ່ລາຍການເຫັນໄດ້ເຕັມທີ່. ຈະຖືກລຶບອອກທັນທີທີ່ລາຍການເລີ່ມຫາຍໄປ. |
gridzyItemVisibleToHidden | ຈະຖືກຕັ້ງຄ່າທັນທີທີ່ລາຍການເລີ່ມຫາຍໄປ. ຈະຖືກລຶບອອກທັນທີທີ່ລາຍການຖືກເຊື່ອງໄວ້ຢ່າງສົມບູນ. |
gridzyItemHidden | ຈະຖືກຕັ້ງທັນທີທີ່ລາຍການຖືກເຊື່ອງໄວ້ຢ່າງສົມບູນ. ຈະຖືກລຶບອອກທັນທີທີ່ລາຍການເລີ່ມປາກົດ. |
gridzyItemHiddenToVisible | ຈະຖືກຕັ້ງໃນທັນທີທີ່ລາຍການເລີ່ມຕົ້ນທີ່ຈະປາກົດຂຶ້ນ (ຍົກເວັ້ນການປະກົດຕົວຄັ້ງທໍາອິດ – ເບິ່ງຫ້ອງ gridzyItemInitialToVisible ). ຈະຖືກເອົາອອກທັນທີທີ່ລາຍການເຫັນໄດ້ຢ່າງສົມບູນ. |
gridzyItemVisibleToVisible | ຈະຖືກຕັ້ງທັນທີທີ່ບາງສິ່ງບາງຢ່າງໃນຕາຂ່າຍໄຟຟ້າມີການປ່ຽນແປງ, ແຕ່ລາຍການຕົວມັນເອງແລະຢູ່ເຫັນໄດ້. ຈະຖືກລຶບອອກທັນທີທີ່ອະນິເມຊັນການປ່ຽນແປງສິ້ນສຸດລົງ. |
ໂດຍຄ່າເລີ່ມຕົ້ນຕົວຊີ້ວັດຂະບວນການແລະພາບເຄື່ອນໄຫວສໍາລັບການປະກົດຕົວແລະຮູບພາບທີ່ຫາຍໄປແມ່ນຖືກກໍານົດໄວ້ລ່ວງຫນ້າໂດຍໄຟລ໌ CSS ຕົ້ນຕໍ Gridzy.
ດ້ວຍຫ້ອງຮຽນ CSS ທີ່ກ່າວມາຂ້າງເທິງນີ້ ເຈົ້າສາມາດສ້າງຕົວຊີ້ບອກຂະບວນການ ແລະພາບເຄື່ອນໄຫວຂອງທ່ານເອງໄດ້. ກ້າເບິ່ງໄຟລ໌ CSS ຫຼັກຂອງ Gridzy, ເພື່ອເຂົ້າໃຈສິ່ງທີ່ເຈົ້າຈະຕ້ອງ override. ບໍ່ມີຄວາມຢ້ານກົວ, ທຸກສິ່ງທຸກຢ່າງແມ່ນເປັນເອກະສານທີ່ດີຢູ່ທີ່ນັ້ນ.
ເພີ່ມປະສິດທິພາບການໂຫຼດ
ຖ້າທ່ານໃຊ້ຫຼາຍຮູບ, ມັນອາດຈະເປັນຄວາມຄິດທີ່ດີທີ່ຈະຊ່ວຍໃຫ້ Gridzy ສ້າງຕາຂ່າຍໄຟຟ້າໄດ້ໄວຂຶ້ນ.
ປ້ອງກັນບໍ່ໃຫ້ຮູບພາບໂດດ
Gridzy ຕ້ອງການອັດຕາສ່ວນຮູບທັງໝົດເພື່ອຄິດໄລ່ຕາຂ່າຍໄຟຟ້າ. ຄວາມຈິງເຫຼົ່ານີ້ສົ່ງຜົນໃຫ້ອົງປະກອບໂດດຖ້າບາງຮູບພາບພ້ອມແລ້ວແລະຄົນອື່ນບໍ່ແມ່ນ. ຮູບພາບຫຼາຍມີ, ຜົນກະທົບນີ້ຫນ້າລໍາຄານຫຼາຍ.
ເພື່ອປ້ອງກັນພຶດຕິກໍານີ້, ພຽງແຕ່ຕັ້ງຄຸນລັກສະນະ width ແລະ height ສໍາລັບອົງປະກອບ img ທັງຫມົດ. ມັນເປັນສິ່ງສໍາຄັນທີ່ຈະກໍານົດຄ່າທີ່ຖືກຕ້ອງສໍາລັບແຕ່ລະຮູບພາບແຕ່ລະຄົນ, ຖ້າບໍ່ດັ່ງນັ້ນຮູບພາບຈະຖືກບິດເບືອນ. ຄ່າທີ່ຖືກຕ້ອງແມ່ນຄວາມກວ້າງແລະຄວາມສູງຕົ້ນສະບັບຂອງຮູບທີ່ກ່ຽວຂ້ອງ:
<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>ຫຼັງຈາກນັ້ນ Gridzy ສາມາດຄິດໄລ່ຕາຂ່າຍໄຟຟ້າໄດ້ທັນທີໂດຍບໍ່ຈໍາເປັນຕ້ອງຮູ້ຂະຫນາດຕົວຈິງຂອງຮູບພາບ.
Lazy Loading
ເພື່ອໂຫລດຮູບພາບທີ່ຢູ່ໃນຊ່ອງເບິ່ງທີ່ເຫັນໄດ້, ພຽງແຕ່ປະຕິບັດຕາມຂັ້ນຕອນເຫຼົ່ານີ້:
- ໃສ່ຄຸນລັກສະນະ
widthແລະheightຕາມທີ່ອະທິບາຍຂ້າງເທິງ (ໃຫ້ແນ່ໃຈວ່າໃຊ້ຄ່າທີ່ຖືກຕ້ອງ) - ແທນທີ່ຄຸນລັກສະນະ
srcທັງໝົດດ້ວຍdata-gridzylazysrcດັ່ງທີ່ສະແດງຢູ່ຂ້າງລຸ່ມ (ຖ້າທ່ານມີຄຸນລັກສະນະsrcsetເຊັ່ນກັນ, ໃຫ້ປ່ຽນແທນພວກມັນດ້ວຍdata-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>ຫຼັງຈາກຂັ້ນຕອນເຫຼົ່ານີ້ຮູບພາບຈະໂຫຼດທັນທີທີ່ພວກເຂົາເຈົ້າຢູ່ໃກ້ຫຼືຢູ່ໃນ viewport ໄດ້.
ຕົວຊີ້ວັດຂະບວນການ
ຕົວຊີ້ບອກຂະບວນການແມ່ນໄອຄອນເຄື່ອນໄຫວຂະໜາດນ້ອຍທີ່ປະກົດຂຶ້ນໃນຂະນະທີ່ກຳລັງໂຫຼດຮູບພາບ. ຖ້າທ່ານໃຊ້ ຄຳບັນຍາຍ ແລະຜິວໜັງ , ຕົວຊີ້ບອກຂະບວນການຈະສະແດງໂດຍອັດຕະໂນມັດ. ຖ້າບໍ່ດັ່ງນັ້ນທ່ານຕ້ອງການປັບບາງ:
- ເອົາແຕ່ລະອົງປະກອບ
imgເຂົ້າໄປໃນອົງປະກອບdiv
(ຫຼືເຂົ້າໄປໃນອົງປະກອບອື່ນໆ - ເບິ່ງ HTML semantic ສໍາລັບເພີ່ມເຕີມ) - ເພີ່ມ class
gridzyImageໃສ່ແຕ່ລະອົງປະກອບimg
<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>ຫຼັງຈາກນັ້ນ, ທ່ານຄວນເບິ່ງຕົວຊີ້ວັດຂະບວນການຖ້າຫາກວ່າຮູບພາບໃຊ້ເວລາໃນການໂຫຼດ.
ການກັ່ນຕອງ
ການກັ່ນຕອງໃນ Gridzy ແມ່ນງ່າຍດາຍຫຼາຍແຕ່ມີອໍານາດ. ບໍ່ວ່າທ່ານຕ້ອງການການກັ່ນຕອງປະເພດໃດ, ມັນເປັນໄປໄດ້ຫຼາຍທີ່ມັນເປັນໄປໄດ້. ທັງຫມົດທີ່ທ່ານຕ້ອງການແມ່ນ, CSS ນ້ອຍແລະອົງປະກອບຮູບແບບ HTML ຈໍານວນຫນຶ່ງ ...
ນີ້ແມ່ນຕົວຢ່າງທີ່ເປັນປະໂຫຍດ:
<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>ໃຫ້ເຮົາສ້າງມັນເທື່ອລະຂັ້ນຕອນ
1. ທໍາອິດພວກເຮົາຕ້ອງການໂຄງສ້າງ HTML ປົກກະຕິຂອງ Gridzy ແລະຕັ້ງຊື່ຫ້ອງຮຽນສໍາລັບລາຍການຄັງທັງຫມົດດັ່ງນັ້ນພວກເຮົາສາມາດກັ່ນຕອງພວກມັນຫຼັງຈາກນັ້ນ.
<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>ໃນຕົວຢ່າງນີ້ພວກເຮົາໃຊ້ພຽງແຕ່ຫນຶ່ງຊັ້ນສໍາລັບແຕ່ລະອົງປະກອບ. ແຕ່ທ່ານຍັງສາມາດຕັ້ງຫຼາຍຊັ້ນຮຽນສໍາລັບອົງປະກອບດຽວ, ຖ້າອົງປະກອບນັ້ນຄວນຈະຊອກຫາໄດ້ຜ່ານຕົວກອງຫຼາຍ.
2. ຫຼັງຈາກນັ້ນ, ພວກເຮົາເພີ່ມບາງປຸ່ມໂດຍຜ່ານທີ່ພວກເຮົາສາມາດປ່ຽນການກັ່ນຕອງຫຼັງຈາກນັ້ນ
<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>ແທນທີ່ຈະເປັນປຸ່ມ, ທ່ານຍັງສາມາດໃຊ້ອົງປະກອບແບບຟອມອື່ນໆເຊັ່ນ: ກ່ອງກາເຄື່ອງຫມາຍ, ປຸ່ມວິທະຍຸ, ເລືອກຊ່ອງຂໍ້ມູນແລະອື່ນໆ.
ດັ່ງທີ່ເຈົ້າສາມາດເຫັນໄດ້, ຄຸນຄ່າຂອງປຸ່ມຕ່າງໆແມ່ນຕົວເລືອກ CSS ປົກກະຕິ. ທັນທີທີ່ພວກເຮົາເຮັດສໍາເລັດ, ການຄລິກໃສ່ປຸ່ມດັ່ງກ່າວຈະສະແດງຮູບພາບທີ່ກົງກັບຕົວເລືອກ CSS ນັ້ນ. ດ້ານວິຊາການມັນພຽງແຕ່ກໍານົດທາງເລືອກ filter ກັບຄ່ານີ້.
ນອກນັ້ນທ່ານຍັງສາມາດໃຊ້ຕົວເລືອກທີ່ສັບສົນຫຼາຍ. ຕົວຢ່າງ :not(.animals) ອາດຈະໃຊ້ໄດ້ຄືກັນ, ເຊັ່ນດຽວກັບ .animals.people ແລະ .animals, .people .
3. ສຸດທ້າຍ, ພວກເຮົາ encapsulate ປຸ່ມໃນຖັງ div ແລະຜູກມັດໃຫ້ເຂົາເຈົ້າກັບ Gridzy gallery, ໂດຍການຕັ້ງຄ່າທາງເລືອກ 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>ດັ່ງທີ່ເຈົ້າສາມາດເຫັນໄດ້, ພວກເຮົາຍັງໃຊ້ຕົວເລືອກ CSS ສໍາລັບຕົວເລືອກ filterControls . ກ່ອງບັນຈຸ div ທີ່ມີຄຸນລັກສະນະ id ພຽງແຕ່ເຮັດຫນ້າທີ່ເພື່ອເຮັດໃຫ້ປຸ່ມຕ່າງໆງ່າຍຕໍ່ການເລືອກໂດຍຜ່ານຕົວເລືອກ CSS ນັ້ນ.
ນັ້ນເອງ!
ຖ້າທ່ານຕ້ອງການການແກ້ໄຂ JavaScript, ກວດເບິ່ງ API .
API
ເຖິງແມ່ນວ່າ Gridzy ມີ API ຂອງຕົນເອງ, ສິ່ງສ່ວນໃຫຍ່ສາມາດເຮັດໄດ້ໂດຍບໍ່ມີມັນ, ພຽງແຕ່ໂດຍການຫມູນໃຊ້ DOM. Gridzy ຈະສັງເກດເຫັນມັນແລະປັບຕາຂ່າຍໄຟຟ້າ. ແຕ່ຍັງມີ API ທີ່ມີປະສິດທິພາບຫຼາຍ ...
ການຈັດການ DOM
ສໍາລັບທຸກ Document Object Model (DOM) manipulations ທໍາອິດພວກເຮົາຕ້ອງການອົງປະກອບ container:
// get the container element
var gridzyElement = document.querySelector('.gridzy');ເພີ່ມຮູບພາບ
ມັນເປັນສິ່ງສໍາຄັນທີ່ຈະສ້າງແລະຕື່ມຂໍ້ມູນໃສ່ອົງປະກອບຂອງເດັກໃຫມ່ກ່ອນທີ່ທ່ານຈະເພີ່ມມັນໃສ່ອົງປະກອບບັນຈຸ. ຖ້າບໍ່ດັ່ງນັ້ນ Gridzy ບໍ່ສາມາດກວດພົບຂະຫນາດທີ່ຖືກຕ້ອງ.
// 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);ລຶບຮູບພາບ
// remove the first image
gridzyElement.removeChild(gridzyElement.firstElementChild);ປ່ຽນຕົວເລືອກ
// 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');ເພີ່ມເຕີມກ່ຽວກັບການຈັດການ DOM ທ່ານສາມາດຊອກຫາໄດ້ຢູ່ MDN web docs . ນອກຈາກນີ້ຍັງມີ ການແນະນໍາກ່ຽວກັບ DOM ທີ່ມີຢູ່.
API ທີ່ເປັນເຈົ້າຂອງ
ເພື່ອນໍາໃຊ້ API, ພວກເຮົາທໍາອິດຕ້ອງການຕົວຢ່າງ Gridzy, ເຊິ່ງຜູກມັດກັບອົງປະກອບຖັງ Gridzy:
// get the Gridzy instance
var gridzyInstance = document.querySelector('.gridzy').gridzy;ເອົາທາງເລືອກ
// get the value of a single option
var currentLayout = gridzyInstance.getOption('layout');ເອົາຕົວເລືອກທັງໝົດ
// get all option values as an object
var currentOptions = gridzyInstance.getOptions();ຕັ້ງຄ່າຕົວເລືອກ
// set specific option values
gridzyInstance.setOptions({
spaceBetween: 10,
layout: 'waterfall'
});
// or reset options to their default values
gridzyInstance.setOptions({
spaceBetween: null,
layout: null
});ນຳໃຊ້ຕົວກອງ
ການນໍາໃຊ້ຕົວກັ່ນຕອງເປັນພຽງແຕ່ການຕັ້ງຕົວ filter ທາງເລືອກທີ່ສາມາດເປັນຕົວເລືອກ CSS ທີ່ຖືກຕ້ອງ:
// 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'
});ເພີ່ມຟັງຊັນໂທກັບ
ເຊົາສະໝັກແລ້ວ ຕັ້ງແຕ່ເວີຊັນ 2.4.0
ໃຊ້ ເຫດການ ທີ່ທັນສະໄໝ ແລະປ່ຽນແປງໄດ້ແທນ. ເບິ່ງພາກຕໍ່ໄປສໍາລັບລາຍລະອຽດ.
Gridzy.js 2 ຮອງຮັບບາງທາງເລືອກສຳລັບຟັງຊັນໂທກັບ. ພວກເຂົາສາມາດຕັ້ງໄດ້ຜ່ານ API ທີ່ເປັນເຈົ້າຂອງເທົ່ານັ້ນ, ແຕ່ຄືກັນກັບທາງເລືອກອື່ນ:
// 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.
}
});ໃຊ້ເຫດການ
ຕັ້ງແຕ່ລຸ້ນ 2.4.0
ທ່ານສາມາດນໍາໃຊ້ເຫດການ Gridzy ຄືກັບເຫດການ 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.
});ເຫດການບາງຢ່າງຖືກຍິງໃສ່ອົງປະກອບຖັງ Gridzy ແລະເຫດການອື່ນໆຖືກຍິງໃສ່ອົງປະກອບຂອງແຕ່ລະລາຍການພາຍໃນອົງປະກອບບັນຈຸ.
ເຫດການຍິງໃສ່ອົງປະກອບຖັງ Gridzy:
event.target ສະໜອງອົງປະກອບຖັງ Gridzy.
event.detail.instance ໃຫ້ຕົວຢ່າງ Gridzy.
ເຫດການທີ່ຍິງຢູ່ໃນອົງປະກອບຂອງລາຍການ:
event.target ໃຫ້ອົງປະກອບລາຍການຕາມລໍາດັບ.
event.detail.instance ໃຫ້ຕົວຢ່າງ Gridzy.
API - ທົ່ວໂລກ
ມີບາງຟັງຊັນທີ່ເປັນເອກະລາດຂອງຕົວຢ່າງ Gridzy. ສະນັ້ນພວກເຮົາບໍ່ ຈຳ ເປັນຕ້ອງເອົາຕົວຢ່າງກ່ອນ.
ເອົາຕົວເລືອກເລີ່ມຕົ້ນ
// get the default value of a single option
var defaultLayout = Gridzy.getDefaultOption('layout');ເອົາຕົວເລືອກເລີ່ມຕົ້ນທັງໝົດ
// 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');ຕັ້ງຄ່າຕົວເລືອກເລີ່ມຕົ້ນ
ນີ້ບໍ່ໄດ້ກໍານົດທາງເລືອກຂອງຕົວຢ່າງ Gridzy ເບື້ອງຕົ້ນທັງຫມົດ, ແຕ່ກໍານົດພື້ນຖານສໍາລັບຕົວຢ່າງໃຫມ່. ຢ່າງໃດກໍຕາມ, ຖ້າທາງເລືອກຂອງຕົວຢ່າງທີ່ມີຢູ່ແລ້ວຈະຖືກຕັ້ງຄ່າໃຫມ່ໂດຍຜ່ານຄ່າ null , ມັນຈະໃຊ້ຄ່າເລີ່ມຕົ້ນໃຫມ່.
// set default option values
Gridzy.setDefaultOptions({
spaceBetween: 10,
layout: 'waterfall'
});ທ່ານສາມາດນໍາໃຊ້ນີ້ເພື່ອກໍານົດທາງເລືອກທົ່ວໂລກ, ຖ້າທ່ານໂທຫາມັນກ່ອນທີ່ DOM ຈະກຽມພ້ອມ. ດັ່ງນັ້ນ, ທ່ານຈະບໍ່ຈໍາເປັນຕ້ອງກໍານົດທາງເລືອກເປັນຄຸນລັກສະນະອີກຕໍ່ໄປ.
ອັດຕະໂນມັດ
ຕາບໃດທີ່ລະບົບອັດຕະໂນມັດທັງໝົດຂອງ Gridzy.js 2 ເຮັດວຽກຢູ່, ມັນບໍ່ຈໍາເປັນຕ້ອງມີວິທີການຂ້າງລຸ່ມນີ້. ແຕ່ລະບົບອັດຕະໂນມັດສາມາດປິດການໃຊ້ Gridzy ໃນແບບດັ້ງເດີມກວ່າ:
// 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
});ບາງທາງເລືອກເຫຼົ່ານີ້ບໍ່ສາມາດຖືກຕັ້ງຜ່ານ data-gridzy- attributes ຫຼືຜ່ານ setOptions() , ເນື່ອງຈາກເຫດຜົນທາງເຫດຜົນ:
ເລີ່ມຕົ້ນດ້ວຍຕົນເອງ
// initialize a new Gridzy instance
var gridzyInstance = new Gridzy(document.querySelector('.gridzy'), {
spaceBetween: 10,
layout: 'waterfall'
});ທໍາລາຍຕົວຢ່າງ
ເວົ້າປະມານ, ກົງກັນຂ້າມກັບການເລີ່ມຕົ້ນ Gridzy.
gridzyInstance.destroy();
gridzyInstance = null;Sync ລາຍຊື່ເດັກດ້ວຍຕົນເອງ
// after child elements (images) are added to or removed from the DOM.
gridzyInstance.syncChildList();ຊິ້ງອົງປະກອບລູກດຽວດ້ວຍຕົນເອງ
ປົກກະຕິແລ້ວບໍ່ຈໍາເປັນ, ຍົກເວັ້ນໃນກໍລະນີທີ່ຫາຍາກຫຼາຍ.
// after child elements (images) are added to the DOM and only one of them should be synced to Gridzy.
gridzyInstance.syncChild(childElement);Sync ຄຸນລັກສະນະດ້ວຍຕົນເອງ
ໃຫ້ສັງເກດວ່າທາງເລືອກ useOptionAttributes ຈະຕ້ອງເປັນ true ສໍາລັບການນີ້.
// after data-gridzy- attributes have changed
gridzyInstance.syncAttributes();ບັງຄັບໃຫ້ສະແດງຜົນ
ປົກກະຕິແລ້ວບໍ່ຈໍາເປັນ, ເຖິງແມ່ນວ່າອັດຕະໂນມັດທັງຫມົດຈະຖືກປິດ
gridzyInstance.render();