ਵੈੱਬਸਾਈਟ ਦਾ ਆਪਣੇ ਆਪ ਅਨੁਵਾਦ ਕੀਤਾ ਗਿਆ ਹੈ। ਜੇਕਰ ਕੁਝ ਸਪੱਸ਼ਟ ਨਹੀਂ ਹੈ, ਤਾਂ ਕਿਰਪਾ ਕਰਕੇ ਅੰਗਰੇਜ਼ੀ ਦਸਤਾਵੇਜ਼ਾਂ 'ਤੇ ਇੱਕ ਨਜ਼ਰ ਮਾਰੋ।
ਮੁੱਢਲੀ ਵਰਤੋਂ
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>ਇਹ ਹੀ ਗੱਲ ਹੈ! ਇਹ ਇੱਕ ਪੂਰੀ ਤਰ੍ਹਾਂ ਕਾਰਜਸ਼ੀਲ ਉਦਾਹਰਣ ਹੈ। ਕੋਈ ਵਾਧੂ ਸ਼ੁਰੂਆਤ ਦੀ ਲੋੜ ਨਹੀਂ ਹੈ।
ਸੰਰਚਨਾ
ਗ੍ਰਿਡਜ਼ੀ ਨੂੰ ਕੌਂਫਿਗਰ ਕਰਨ ਦਾ ਸਭ ਤੋਂ ਆਸਾਨ ਤਰੀਕਾ ਹੈ, ਸਿਰਫ HTML ਵਿਸ਼ੇਸ਼ਤਾਵਾਂ ਦੀ ਵਰਤੋਂ ਕਰਨਾ। ਤੁਹਾਨੂੰ ਸਿਰਫ਼ data-gridzy- ਨਾਲ ਵਿਕਲਪ ਨਾਮਾਂ ਦਾ ਅਗੇਤਰ ਲਗਾਉਣ ਦੀ ਲੋੜ ਹੈ। ਇਸ ਲਈ, spaceBetween ਵਿਕਲਪ ਨੂੰ ਸੈੱਟ ਕਰਨ ਲਈ, ਸਿਰਫ਼ 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 ਬਣਤਰ ਇਹ ਹੈ:
<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>ਹਾਲਾਂਕਿ, ਗ੍ਰਿਡਜ਼ੀ ਬਹੁਤ ਲਚਕਦਾਰ ਹੈ ਅਤੇ ਤੁਸੀਂ ਲਗਭਗ ਕਿਸੇ ਵੀ ਹੋਰ HTML ਢਾਂਚੇ ਦੀ ਵਰਤੋਂ ਕਰ ਸਕਦੇ ਹੋ. ਵਿਚਾਰਨ ਲਈ ਸਿਰਫ ਕੁਝ ਨੁਕਤੇ ਹਨ:
- ਕੰਟੇਨਰ ਤੱਤ ਦਾ ਹਰੇਕ ਬੱਚਾ ਗਰਿੱਡ ਵਿੱਚ ਇੱਕ ਆਈਟਮ ਨੂੰ ਦਰਸਾਉਂਦਾ ਹੈ।
- ਕੰਟੇਨਰ ਤੱਤ ਅਤੇ ਇਸਦੇ ਬੱਚੇ ਦੋਵੇਂ ਕਿਸੇ ਵੀ ਟੈਗ ਕਿਸਮ ਦੇ ਹੋ ਸਕਦੇ ਹਨ, ਜਿਵੇਂ ਕਿ
ulਅਤੇli(ਸਿਰਫ਼ ਬ੍ਰਾਊਜ਼ਰ ਡਿਫੌਲਟ ਰੀਸੈਟ ਕਰਨ ਲਈ ਵਿਚਾਰ ਕਰੋ)। - ਜੇਕਰ ਇੱਕ
imgਤੱਤ ਖੁਦ ਇੱਕ ਸਿੱਧਾ ਬੱਚਾ ਨਹੀਂ ਹੈ, ਤਾਂ ਇਸਨੂੰgridzyImageਕਲਾਸ ਦੀ ਲੋੜ ਹੈ।
ਇਸ ਲਈ ਇਹ ਇੱਕ ਕਾਰਜਸ਼ੀਲ 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 ਢਾਂਚੇ ਦੀ ਲੋੜ ਹੈ। ਇਸ ਬਾਰੇ ਹੋਰ ਜਾਣਨ ਲਈ, ਕੈਪਸ਼ਨ ਅਤੇ ਸਕਿਨ ' ਤੇ ਇੱਕ ਨਜ਼ਰ ਮਾਰੋ।
ਸੁਰਖੀਆਂ ਅਤੇ ਛਿੱਲ
ਜੇਕਰ ਤੁਸੀਂ ਆਪਣੀ ਗੈਲਰੀ ਵਿੱਚ ਸੁਰਖੀਆਂ ਜੋੜਨਾ ਚਾਹੁੰਦੇ ਹੋ, ਤਾਂ ਤੁਹਾਨੂੰ ਦਿੱਖ ਨੂੰ ਪਰਿਭਾਸ਼ਿਤ ਕਰਨ ਦੀ ਲੋੜ ਹੈ। ਇਸ ਲਈ, ਕੁਝ ਪਰਿਭਾਸ਼ਿਤ ਸਕਿਨ ਉਪਲਬਧ ਹਨ. ਹਰੇਕ ਚਮੜੀ ਜਿਸ ਵਿੱਚ ਇੱਕ 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 ਢਾਂਚੇ ਬਾਰੇ ਸੋਚ ਰਹੇ ਹੋ, ਤਾਂ ਸਿਮੈਂਟਿਕ HTML ' ਤੇ ਇੱਕ ਨਜ਼ਰ ਮਾਰੋ।
ਕੈਪਸ਼ਨ ਲਈ ਤੁਸੀਂ ਕਿਸੇ ਵੀ ਕਿਸਮ ਦੇ ਟੈਗ ਦੀ ਵਰਤੋਂ ਕਰ ਸਕਦੇ ਹੋ, ਬੱਸ ਇਹ ਯਕੀਨੀ ਬਣਾਓ ਕਿ ਇਸ ਵਿੱਚ ਕਲਾਸ gridzyCaption ਹੈ। img ਤੱਤ ਨੂੰ gridzyImage ਕਲਾਸ ਦੀ ਲੋੜ ਹੈ।
ਉਪਰੋਕਤ ਉਦਾਹਰਨ ਤੁਹਾਨੂੰ ਚਮੜੀ gridzySkinClassic ਦਿਖਾਉਂਦਾ ਹੈ। ਕਿਸੇ ਵੱਖਰੇ ਦੀ ਵਰਤੋਂ ਕਰਨ ਲਈ, ਚਮੜੀ ਦੇ ਨਾਮ ਨੂੰ ਇਹਨਾਂ ਵਿੱਚੋਂ ਇੱਕ ਨਾਲ ਬਦਲੋ:
ਸਕਿਨ ਸ਼ਾਮਲ ਹਨ
| ਉਪਲਬਧ ਕਲਾਸਾਂ | |
|---|---|
| gridzySkinBlank ਆਪਣੀ ਚਮੜੀ ਬਣਾਉਣ ਲਈ ਇੱਕ ਵਧੀਆ ਸ਼ੁਰੂਆਤੀ ਬਿੰਦੂ ਲਾਈਵ ਝਲਕ | gridzySkinBlank |
| gridzySkinClassic ਲਾਈਵ ਝਲਕ | gridzySkinClassic(ਵਰਜਨ 2.6.0 ਤੋਂ ਬਰਤਰਫ਼) |
| gridzySkinFullOverlay ਲਾਈਵ ਝਲਕ | gridzySkinFullOverlay(ਵਰਜਨ 2.6.0 ਤੋਂ ਬਰਤਰਫ਼) |
| gridzySkinLift ਲਾਈਵ ਝਲਕ | gridzySkinLift(ਵਰਜਨ 2.6.0 ਤੋਂ ਬਰਤਰਫ਼) |
| gridzySkinMagnifier ਜ਼ੂਮ ਕਾਰਜਕੁਸ਼ਲਤਾ ਸ਼ਾਮਲ ਨਹੀਂ ਹੈ ਲਾਈਵ ਝਲਕ | gridzySkinMagnifier(ਵਰਜਨ 2.6.0 ਤੋਂ ਬਰਤਰਫ਼) |
ਉਪਰੋਕਤ ਸਾਰੀਆਂ ਸਕਿਨਾਂ ਨੂੰ ਸਿਰਫ਼ ਇੱਕ CSS ਫਾਈਲ ਦੀ ਲੋੜ ਹੁੰਦੀ ਹੈ, ਪਰ ਇੱਥੇ ਵਾਧੂ ਸਕਿਨ ਵੀ ਹਨ ਜਿਨ੍ਹਾਂ ਲਈ 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 ਟੈਕਸਟ-ਸ਼ੈਡੋ ਮੁੱਲ ਦੀ ਆਗਿਆ ਦਿੰਦਾ ਹੈ |
gridzySkinFullOverlay
| ਵੇਰੀਏਬਲ | ਪੂਰਵ-ਨਿਰਧਾਰਤ ਮੁੱਲ | ਜਾਣਕਾਰੀ |
|---|---|---|
--background | rgba(0, 0, 0, .7) | ਕਿਸੇ ਵੀ CSS ਪਿਛੋਕੜ ਮੁੱਲ ਦੀ ਆਗਿਆ ਦਿੰਦਾ ਹੈ |
--color | rgb(255, 255, 255) | ਕਿਸੇ ਵੀ CSS ਰੰਗ ਮੁੱਲ ਦੀ ਆਗਿਆ ਦਿੰਦਾ ਹੈ |
--text-shadow | none | ਕਿਸੇ ਵੀ CSS ਟੈਕਸਟ-ਸ਼ੈਡੋ ਮੁੱਲ ਦੀ ਆਗਿਆ ਦਿੰਦਾ ਹੈ |
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 ਟੈਕਸਟ-ਸ਼ੈਡੋ ਮੁੱਲ ਦੀ ਆਗਿਆ ਦਿੰਦਾ ਹੈ |
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 ਟੈਕਸਟ-ਸ਼ੈਡੋ ਮੁੱਲ ਦੀ ਆਗਿਆ ਦਿੰਦਾ ਹੈ |
gridzySkinCard
| ਵੇਰੀਏਬਲ | ਪੂਰਵ-ਨਿਰਧਾਰਤ ਮੁੱਲ | ਜਾਣਕਾਰੀ |
|---|---|---|
--background | rgba(0, 0, 0, 1) | ਕਿਸੇ ਵੀ CSS ਪਿਛੋਕੜ ਮੁੱਲ ਦੀ ਆਗਿਆ ਦਿੰਦਾ ਹੈ |
--color | rgb(255, 255, 255) | ਕਿਸੇ ਵੀ CSS ਰੰਗ ਮੁੱਲ ਦੀ ਆਗਿਆ ਦਿੰਦਾ ਹੈ |
--text-shadow | none | ਕਿਸੇ ਵੀ CSS ਟੈਕਸਟ-ਸ਼ੈਡੋ ਮੁੱਲ ਦੀ ਆਗਿਆ ਦਿੰਦਾ ਹੈ |
ਸਾਰੀਆਂ ਪੂਰਵ-ਪ੍ਰਭਾਸ਼ਿਤ ਸਕਿਨ ਸਿਰਫ਼ ਸਧਾਰਨ ਟੈਕਸਟ ਸੁਰਖੀਆਂ ਦਾ ਸਮਰਥਨ ਕਰਦੀਆਂ ਹਨ। ਤੁਸੀਂ ਆਪਣੀ ਖੁਦ ਦੀ ਅਤੇ ਵਧੇਰੇ ਗੁੰਝਲਦਾਰ ਛਿੱਲ ਬਣਾ ਸਕਦੇ ਹੋ। ਕਿਰਪਾ ਕਰਕੇ ਸਟਾਈਲ ਗ੍ਰਿਡਜ਼ੀ ' ਤੇ ਇੱਕ ਨਜ਼ਰ ਮਾਰੋ।
ਸ਼ੈਲੀ 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 ਕਲਾਸਾਂ ਪਾਓਗੇ। ਗ੍ਰਿਡਜ਼ੀ ਨੂੰ ਖੁਦ ਇਹਨਾਂ ਕਲਾਸਾਂ ਦੀ ਲੋੜ ਨਹੀਂ ਹੈ। ਉਹ ਸਿਰਫ ਸਟਾਈਲਿੰਗ ਲਈ ਵਰਤੇ ਜਾਂਦੇ ਹਨ ਅਤੇ ਇਸਲਈ ਜੇਕਰ ਤੁਸੀਂ ਚਾਹੋ ਤਾਂ ਉਹਨਾਂ ਨੂੰ ਹਟਾ ਜਾਂ ਨਾਮ ਬਦਲ ਸਕਦੇ ਹੋ।
ਇਸ ਤੋਂ ਇਲਾਵਾ ਤੁਹਾਨੂੰ CSS ਕਲਾਸ gridzyItem ਮਿਲੇਗਾ। Gridzy ਮੁੱਖ ਕੰਟੇਨਰ ਤੱਤ ਦੇ ਸਾਰੇ ਸਿੱਧੇ ਬੱਚਿਆਂ ਲਈ ਇਸ ਕਲਾਸ ਨੂੰ ਆਪਣੇ ਆਪ ਸੈੱਟ ਕਰਦਾ ਹੈ। ਇਸ ਲਈ, ਤੁਸੀਂ ਇਸ ਕਲਾਸ ਦੀ ਵਰਤੋਂ ਆਪਣੀ ਗੈਲਰੀ ਦੀਆਂ ਚੀਜ਼ਾਂ ਨੂੰ ਸਟਾਈਲ ਕਰਨ ਲਈ ਕਰ ਸਕਦੇ ਹੋ।
ਮਨ ਜ਼ਰੂਰੀ ਗੱਲਾਂ
- ਆਈਟਮ ਸਮੱਗਰੀ ਪੂਰੀ ਤਰ੍ਹਾਂ ਜਵਾਬਦੇਹ ਹੋਣੀ ਚਾਹੀਦੀ ਹੈ। ਵਿਚਾਰ ਕਰੋ ਕਿ ਤੱਤ ਦਾ ਆਕਾਰ ਯਕੀਨੀ ਤੌਰ 'ਤੇ ਬਦਲ ਜਾਵੇਗਾ. ਪਿਕਸਲ ਮੁੱਲਾਂ ਦੀ ਬਜਾਏ ਪ੍ਰਤੀਸ਼ਤ ਮੁੱਲਾਂ ਦੀ ਵਰਤੋਂ ਕਰੋ। ਅਤੇ Gridzy ਲੇਆਉਟ ਵਿਕਲਪ
autoFontSize'ਤੇ ਇੱਕ ਨਜ਼ਰ ਮਾਰੋ, ਜੋ ਫੌਂਟ-ਸਾਈਜ਼ ਨੂੰ ਆਈਟਮ ਬਾਕਸ ਦੇ ਆਕਾਰ ਨਾਲ ਜੋੜਦਾ ਹੈ। - ਹਰੇਕ ਆਈਟਮ ਦਾ ਚੰਗੀ ਤਰ੍ਹਾਂ ਪਰਿਭਾਸ਼ਿਤ ਪੱਖ ਅਨੁਪਾਤ ਹੋਣਾ ਚਾਹੀਦਾ ਹੈ। ਆਈਟਮ ਦਾ ਆਕਾਰ ਅਨੁਪਾਤ ਕਦੇ ਨਹੀਂ ਬਦਲੇਗਾ ਅਤੇ ਗਰਿੱਡ ਦੀ ਗਣਨਾ ਕਰਨ ਲਈ ਲੋੜੀਂਦਾ ਹੈ। ਇਸ ਲਈ ਜੇਕਰ ਕਿਸੇ ਆਈਟਮ ਦਾ ਸਵੈਚਲਿਤ ਤੌਰ 'ਤੇ ਚੰਗੀ ਤਰ੍ਹਾਂ ਪਰਿਭਾਸ਼ਿਤ ਪੱਖ ਅਨੁਪਾਤ ਨਹੀਂ ਹੈ, ਤਾਂ ਇਸਨੂੰ ਹੱਥੀਂ ਪਰਿਭਾਸ਼ਿਤ ਕਰੋ (ਉਦਾਹਰਨ ਲਈ css ਰਾਹੀਂ)।
ਕੁਝ ਮਾਮਲਿਆਂ ਵਿੱਚ, ਗ੍ਰਿਡਜ਼ੀ ਦੇ ਸ਼ੁਰੂ ਹੋਣ ਤੋਂ ਪਹਿਲਾਂ ਆਈਟਮਾਂ ਦੀ ਸਮੱਗਰੀ ਨੂੰ ਸਟਾਈਲ ਕਰਨਾ ਆਸਾਨ ਹੋ ਸਕਦਾ ਹੈ। ਬਸ ਇਸਦੇ ਲਈ ਕਲਾਸ gridzy ਜਾਂ ਗ੍ਰਿਡਜ਼ੀ ਜਾਵਾਸਕ੍ਰਿਪਟ ਫਾਈਲ ਨੂੰ ਅਸਥਾਈ ਤੌਰ 'ਤੇ ਹਟਾਓ।
ਇਹ ਹੀ ਗੱਲ ਹੈ! ਬੱਸ ਤੁਹਾਨੂੰ ਆਪਣੀ ਖੁਦ ਦੀ ਚਮੜੀ ਬਣਾਉਣ ਦੀ ਲੋੜ ਹੈ। ਜ਼ਿਆਦਾਤਰ ਪਰਿਭਾਸ਼ਿਤ ਸਕਿਨ ਇਸ ਤੋਂ ਵੱਧ ਨਹੀਂ ਵਰਤਦੀਆਂ।
ਪਰ ਜੇ ਤੁਸੀਂ ਚਾਹੁੰਦੇ ਹੋ ਤਾਂ ਹੋਰ ਵੀ ਹੋ ਸਕਦਾ ਹੈ ...
ਉੱਨਤ ਛਿੱਲ
Gridzy ਸਿਰਫ਼ gridzyItem ਨਾਲੋਂ ਜ਼ਿਆਦਾ CSS ਕਲਾਸਾਂ ਦੀ ਵਰਤੋਂ ਕਰਦਾ ਹੈ। ਉਹਨਾਂ ਵਿੱਚੋਂ ਜ਼ਿਆਦਾਤਰ ਆਪਣੇ ਆਪ ਸੈੱਟ ਹੋ ਜਾਣਗੇ ਅਤੇ ਤੁਸੀਂ ਉਹਨਾਂ ਨੂੰ ਸਟਾਈਲਿੰਗ ਲਈ ਵੀ ਵਰਤ ਸਕਦੇ ਹੋ।
ਮੁੱਖ ਕੰਟੇਨਰ ਕਲਾਸਾਂ
| ਕਲਾਸ ਦਾ ਨਾਮ | ਵਰਣਨ |
|---|---|
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 ਫਾਈਲ ਦੁਆਰਾ ਪਹਿਲਾਂ ਤੋਂ ਪਰਿਭਾਸ਼ਿਤ ਕੀਤਾ ਗਿਆ ਹੈ।
ਇਹਨਾਂ ਉਪਰੋਕਤ CSS ਕਲਾਸਾਂ ਦੇ ਨਾਲ ਤੁਸੀਂ ਆਪਣੇ ਖੁਦ ਦੇ ਪ੍ਰਕਿਰਿਆ ਸੂਚਕ ਅਤੇ ਐਨੀਮੇਸ਼ਨਾਂ ਨੂੰ ਸਟਾਈਲ ਕਰ ਸਕਦੇ ਹੋ. ਇਹ ਸਮਝਣ ਲਈ ਕਿ ਤੁਹਾਨੂੰ ਕੀ ਓਵਰਰਾਈਡ ਕਰਨਾ ਪਏਗਾ, Gridzy ਮੁੱਖ CSS ਫਾਈਲ ਵਿੱਚ ਇੱਕ ਨਜ਼ਰ ਮਾਰਨ ਦੀ ਹਿੰਮਤ ਕਰੋ। ਕੋਈ ਡਰ ਨਹੀਂ, ਇੱਥੇ ਸਭ ਕੁਝ ਚੰਗੀ ਤਰ੍ਹਾਂ ਦਸਤਾਵੇਜ਼ੀ ਹੈ।
ਲੋਡਿੰਗ ਨੂੰ ਅਨੁਕੂਲ ਬਣਾਓ
ਜੇਕਰ ਤੁਸੀਂ ਬਹੁਤ ਸਾਰੀਆਂ ਤਸਵੀਰਾਂ ਦੀ ਵਰਤੋਂ ਕਰਦੇ ਹੋ, ਤਾਂ ਗ੍ਰਿਡਜ਼ੀ ਨੂੰ ਤੇਜ਼ੀ ਨਾਲ ਗਰਿੱਡ ਬਣਾਉਣ ਵਿੱਚ ਮਦਦ ਕਰਨਾ ਇੱਕ ਚੰਗਾ ਵਿਚਾਰ ਹੋ ਸਕਦਾ ਹੈ।
ਜੰਪਿੰਗ ਚਿੱਤਰਾਂ ਨੂੰ ਰੋਕੋ
ਗ੍ਰਿਡਜ਼ੀ ਨੂੰ ਗਰਿੱਡ ਦੀ ਗਣਨਾ ਕਰਨ ਲਈ ਸਾਰੀਆਂ ਤਸਵੀਰਾਂ ਦੇ ਆਕਾਰ ਅਨੁਪਾਤ ਦੀ ਬਿਲਕੁਲ ਲੋੜ ਹੈ। ਇਹ ਤੱਥ ਜੰਪਿੰਗ ਐਲੀਮੈਂਟਸ ਦੇ ਨਤੀਜੇ ਵਜੋਂ ਜੇ ਕੁਝ ਚਿੱਤਰ ਤਿਆਰ ਹਨ ਅਤੇ ਹੋਰ ਨਹੀਂ ਹਨ. ਜਿੰਨੇ ਜ਼ਿਆਦਾ ਚਿੱਤਰ ਹਨ, ਓਨਾ ਹੀ ਜ਼ਿਆਦਾ ਤੰਗ ਕਰਨ ਵਾਲਾ ਇਹ ਪ੍ਰਭਾਵ ਹੋ ਸਕਦਾ ਹੈ।
ਇਸ ਵਿਵਹਾਰ ਨੂੰ ਰੋਕਣ ਲਈ, ਸਾਰੇ img ਤੱਤਾਂ ਲਈ ਸਿਰਫ਼ width ਅਤੇ height ਵਿਸ਼ੇਸ਼ਤਾਵਾਂ ਸੈਟ ਕਰੋ। ਹਰੇਕ ਵਿਅਕਤੀਗਤ ਚਿੱਤਰ ਲਈ ਸਹੀ ਮੁੱਲ ਨਿਰਧਾਰਤ ਕਰਨਾ ਮਹੱਤਵਪੂਰਨ ਹੈ, ਨਹੀਂ ਤਾਂ ਚਿੱਤਰ ਵਿਗੜ ਜਾਣਗੇ। ਸਹੀ ਮੁੱਲ ਸੰਬੰਧਿਤ ਚਿੱਤਰ ਦੀ ਅਸਲ ਚੌੜਾਈ ਅਤੇ ਉਚਾਈ ਹਨ:
<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>ਇਸ ਤੋਂ ਬਾਅਦ ਗ੍ਰਿਡਜ਼ੀ ਚਿੱਤਰਾਂ ਦੇ ਅਸਲ ਆਕਾਰਾਂ ਨੂੰ ਜਾਣਨ ਦੀ ਲੋੜ ਤੋਂ ਬਿਨਾਂ ਤੁਰੰਤ ਗਰਿੱਡ ਦੀ ਗਣਨਾ ਕਰ ਸਕਦਾ ਹੈ।
ਆਲਸੀ ਲੋਡਿੰਗ
ਸਿਰਫ਼ ਉਹਨਾਂ ਚਿੱਤਰਾਂ ਨੂੰ ਲੋਡ ਕਰਨ ਲਈ ਜੋ ਦਿਸਣਯੋਗ ਵਿਊਪੋਰਟ ਵਿੱਚ ਹਨ, ਸਿਰਫ਼ ਇਹਨਾਂ ਕਦਮਾਂ ਦੀ ਪਾਲਣਾ ਕਰੋ:
- ਉੱਪਰ ਦੱਸੇ ਅਨੁਸਾਰ
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>ਇਹਨਾਂ ਕਦਮਾਂ ਤੋਂ ਬਾਅਦ ਤਸਵੀਰਾਂ ਜਿਵੇਂ ਹੀ ਵਿਊਪੋਰਟ ਦੇ ਨੇੜੇ ਜਾਂ ਅੰਦਰ ਹੋਣਗੀਆਂ ਲੋਡ ਹੋ ਜਾਣਗੀਆਂ।
ਪ੍ਰਕਿਰਿਆ ਸੂਚਕ
ਪ੍ਰਕਿਰਿਆ ਸੂਚਕ ਇੱਕ ਛੋਟਾ ਐਨੀਮੇਟਡ ਆਈਕਨ ਹੁੰਦਾ ਹੈ ਜੋ ਚਿੱਤਰ ਦੇ ਲੋਡ ਹੋਣ ਵੇਲੇ ਦਿਖਾਈ ਦਿੰਦਾ ਹੈ। ਜੇਕਰ ਤੁਸੀਂ ਸੁਰਖੀਆਂ ਅਤੇ ਛਿੱਲਾਂ ਦੀ ਵਰਤੋਂ ਕਰਦੇ ਹੋ, ਤਾਂ ਪ੍ਰਕਿਰਿਆ ਸੂਚਕ ਆਪਣੇ ਆਪ ਦਿਖਾਈ ਦੇਵੇਗਾ। ਨਹੀਂ ਤਾਂ ਤੁਹਾਨੂੰ ਕੁਝ ਵਿਵਸਥਾਵਾਂ ਦੀ ਲੋੜ ਹੈ:
- ਹਰੇਕ
imgਐਲੀਮੈਂਟ ਨੂੰ ਇੱਕdivਐਲੀਮੈਂਟ ਵਿੱਚ ਪਾਓ
(ਜਾਂ ਕਿਸੇ ਹੋਰ ਤੱਤ ਵਿੱਚ - ਹੋਰ ਲਈ ਸਿਮੈਂਟਿਕ HTML ਦੇਖੋ) - ਕਲਾਸ
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 ਢਾਂਚੇ ਦੀ ਲੋੜ ਹੈ ਅਤੇ ਸਾਰੀਆਂ ਗੈਲਰੀ ਆਈਟਮਾਂ ਲਈ ਕਲਾਸ ਦੇ ਨਾਮ ਸੈੱਟ ਕਰੋ ਤਾਂ ਜੋ ਅਸੀਂ ਉਹਨਾਂ ਨੂੰ ਬਾਅਦ ਵਿੱਚ ਫਿਲਟਰ ਕਰ ਸਕੀਏ।
<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. ਅੰਤ ਵਿੱਚ, ਅਸੀਂ ਇੱਕ div ਕੰਟੇਨਰ ਵਿੱਚ ਬਟਨਾਂ ਨੂੰ ਐਨਕੈਪਸੂਲੇਟ ਕਰਦੇ ਹਾਂ ਅਤੇ 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>ਜਿਵੇਂ ਕਿ ਤੁਸੀਂ ਵੇਖ ਸਕਦੇ ਹੋ, ਅਸੀਂ filterControls ਵਿਕਲਪ ਲਈ ਇੱਕ CSS ਚੋਣਕਾਰ ਦੀ ਵਰਤੋਂ ਵੀ ਕਰਦੇ ਹਾਂ। id ਵਿਸ਼ੇਸ਼ਤਾ ਵਾਲਾ div ਕੰਟੇਨਰ ਸਿਰਫ਼ ਉਸ CSS ਚੋਣਕਾਰ ਰਾਹੀਂ ਬਟਨਾਂ ਨੂੰ ਚੁਣਨਾ ਆਸਾਨ ਬਣਾਉਣ ਲਈ ਕੰਮ ਕਰਦਾ ਹੈ।
ਇਹ ਹੀ ਗੱਲ ਹੈ!
ਜੇਕਰ ਤੁਸੀਂ JavaScript ਹੱਲ ਨੂੰ ਤਰਜੀਹ ਦਿੰਦੇ ਹੋ, ਤਾਂ API ਨੂੰ ਦੇਖੋ।
API
ਹਾਲਾਂਕਿ Gridzy ਦਾ ਆਪਣਾ API ਹੈ, ਜ਼ਿਆਦਾਤਰ ਚੀਜ਼ਾਂ ਇਸ ਤੋਂ ਬਿਨਾਂ ਕੀਤੀਆਂ ਜਾ ਸਕਦੀਆਂ ਹਨ, ਸਿਰਫ਼ DOM ਨੂੰ ਹੇਰਾਫੇਰੀ ਕਰਕੇ. Gridzy ਇਸ ਨੂੰ ਨੋਟਿਸ ਕਰੇਗਾ ਅਤੇ ਗਰਿੱਡ ਨੂੰ ਅਨੁਕੂਲ ਕਰੇਗਾ. ਪਰ ਇੱਕ ਬਹੁਤ ਸ਼ਕਤੀਸ਼ਾਲੀ API ਵੀ ਹੈ ...
DOM ਨਾਲ ਹੇਰਾਫੇਰੀ ਕਰਨਾ
ਸਾਰੇ ਦਸਤਾਵੇਜ਼ ਆਬਜੈਕਟ ਮਾਡਲ (DOM) ਹੇਰਾਫੇਰੀ ਲਈ ਸਾਨੂੰ ਪਹਿਲਾਂ ਕੰਟੇਨਰ ਤੱਤ ਦੀ ਲੋੜ ਹੈ:
// 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 ਵੈੱਬ ਡੌਕਸ 'ਤੇ ਲੱਭ ਸਕਦੇ ਹੋ। 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 ਤੋਂ
ਤੁਸੀਂ ਆਮ 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 ਕੰਟੇਨਰ ਤੱਤ 'ਤੇ ਫਾਇਰ ਕੀਤੇ ਇਵੈਂਟ:
event.target ਗ੍ਰਿਡਜ਼ੀ ਕੰਟੇਨਰ ਤੱਤ ਪ੍ਰਦਾਨ ਕਰਦਾ ਹੈ।
event.detail.instance Gridzy ਉਦਾਹਰਨ ਪ੍ਰਦਾਨ ਕਰਦਾ ਹੈ।
ਆਈਟਮ ਤੱਤਾਂ 'ਤੇ ਫਾਇਰ ਕੀਤੇ ਇਵੈਂਟ:
event.target ਸੰਬੰਧਿਤ ਆਈਟਮ ਤੱਤ ਪ੍ਰਦਾਨ ਕਰਦਾ ਹੈ।
event.detail.instance Gridzy ਉਦਾਹਰਨ ਪ੍ਰਦਾਨ ਕਰਦਾ ਹੈ।
API - ਗਲੋਬਲ
ਕੁਝ ਫੰਕਸ਼ਨ ਹਨ ਜੋ ਗ੍ਰਿਡਜ਼ੀ ਉਦਾਹਰਨਾਂ ਤੋਂ ਸੁਤੰਤਰ ਹਨ। ਇਸ ਲਈ ਸਾਨੂੰ ਪਹਿਲਾਂ ਕੋਈ ਉਦਾਹਰਣ ਲੈਣ ਦੀ ਲੋੜ ਨਹੀਂ ਹੈ।
ਡਿਫੌਲਟ ਵਿਕਲਪ ਪ੍ਰਾਪਤ ਕਰੋ
// 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');ਡਿਫੌਲਟ ਵਿਕਲਪ ਸੈੱਟ ਕਰੋ
ਇਹ ਪਹਿਲਾਂ ਤੋਂ ਹੀ ਸ਼ੁਰੂ ਕੀਤੇ ਗਏ ਸਾਰੇ ਗ੍ਰਿਡਜ਼ੀ ਉਦਾਹਰਨਾਂ ਦੇ ਵਿਕਲਪਾਂ ਨੂੰ ਸੈੱਟ ਨਹੀਂ ਕਰਦਾ ਹੈ, ਪਰ ਨਵੀਆਂ ਉਦਾਹਰਣਾਂ ਲਈ ਆਧਾਰ ਨੂੰ ਪਰਿਭਾਸ਼ਿਤ ਕਰਦਾ ਹੈ। ਹਾਲਾਂਕਿ, ਜੇਕਰ ਕਿਸੇ ਮੌਜੂਦਾ ਉਦਾਹਰਣ ਦਾ ਵਿਕਲਪ ਮੁੱਲ null ਦੁਆਰਾ ਰੀਸੈਟ ਕੀਤਾ ਜਾਵੇਗਾ, ਤਾਂ ਇਹ ਨਵੇਂ ਮੂਲ ਮੁੱਲ ਦੀ ਵਰਤੋਂ ਕਰੇਗਾ।
// set default option values
Gridzy.setDefaultOptions({
spaceBetween: 10,
layout: 'waterfall'
});ਤੁਸੀਂ ਇਸਦੀ ਵਰਤੋਂ ਵਿਸ਼ਵ ਪੱਧਰ 'ਤੇ ਵਿਕਲਪਾਂ ਨੂੰ ਸੈੱਟ ਕਰਨ ਲਈ ਕਰ ਸਕਦੇ ਹੋ, ਜੇਕਰ ਤੁਸੀਂ DOM ਦੇ ਤਿਆਰ ਹੋਣ ਤੋਂ ਪਹਿਲਾਂ ਇਸ ਨੂੰ ਕਾਲ ਕਰਦੇ ਹੋ। ਇਸ ਲਈ ਤੁਹਾਨੂੰ ਹੁਣ ਵਿਸ਼ੇਸ਼ਤਾਵਾਂ ਦੇ ਤੌਰ 'ਤੇ ਵਿਕਲਪਾਂ ਨੂੰ ਸੈੱਟ ਕਰਨ ਦੀ ਲੋੜ ਨਹੀਂ ਪਵੇਗੀ।
ਆਟੋਮੈਟਿਜ਼ਮ
ਜਿੰਨਾ ਚਿਰ Gridzy.js 2 ਦੇ ਸਾਰੇ ਆਟੋਮੈਟਿਜ਼ਮ ਕਿਰਿਆਸ਼ੀਲ ਹਨ, ਹੇਠਾਂ ਦਿੱਤੇ ਤਰੀਕਿਆਂ ਦੀ ਕੋਈ ਲੋੜ ਨਹੀਂ ਹੈ। ਪਰ ਆਟੋਮੈਟਿਜ਼ਮ ਨੂੰ ਵਧੇਰੇ ਰਵਾਇਤੀ ਤਰੀਕੇ ਨਾਲ ਗ੍ਰਿਡਜ਼ੀ ਦੀ ਵਰਤੋਂ ਕਰਨ ਲਈ ਬੰਦ ਕੀਤਾ ਜਾ ਸਕਦਾ ਹੈ:
// 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- ਗੁਣਾਂ ਰਾਹੀਂ ਜਾਂ setOptions() ਰਾਹੀਂ ਸੈੱਟ ਨਹੀਂ ਕੀਤਾ ਜਾ ਸਕਦਾ ਹੈ:
ਹੱਥੀਂ ਸ਼ੁਰੂ ਕਰੋ
// initialize a new Gridzy instance
var gridzyInstance = new Gridzy(document.querySelector('.gridzy'), {
spaceBetween: 10,
layout: 'waterfall'
});ਉਦਾਹਰਣ ਨੂੰ ਨਸ਼ਟ ਕਰੋ
ਮੋਟੇ ਤੌਰ 'ਤੇ ਕਿਹਾ ਗਿਆ ਹੈ, ਗ੍ਰਿਡਜ਼ੀ ਨੂੰ ਸ਼ੁਰੂ ਕਰਨ ਦੇ ਉਲਟ.
gridzyInstance.destroy();
gridzyInstance = null;ਬਾਲ ਸੂਚੀ ਨੂੰ ਹੱਥੀਂ ਸਿੰਕ ਕਰੋ
// 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);ਗੁਣਾਂ ਨੂੰ ਹੱਥੀਂ ਸਿੰਕ ਕਰੋ
ਨੋਟ ਕਰੋ ਕਿ useOptionAttributes ਵਿਕਲਪ ਇਸ ਲਈ true ਹੋਣਾ ਚਾਹੀਦਾ ਹੈ।
// after data-gridzy- attributes have changed
gridzyInstance.syncAttributes();ਫੋਰਸ ਰੈਂਡਰਿੰਗ
ਆਮ ਤੌਰ 'ਤੇ ਲੋੜ ਨਹੀਂ ਹੁੰਦੀ, ਭਾਵੇਂ ਸਾਰੇ ਆਟੋਮੇਟਿਜ਼ਮ ਬੰਦ ਹੋਣ
gridzyInstance.render();