Skip to content
This repository was archived by the owner on Nov 19, 2024. It is now read-only.

Commit 74c3840

Browse files
authored
Merge pull request #8556 from DashukVolodymyr/gallery-widget-add-example
magento/devdocs#: added example of using the gallery widget
2 parents 049f721 + d07e460 commit 74c3840

File tree

1 file changed

+53
-0
lines changed

1 file changed

+53
-0
lines changed

src/guides/v2.3/javascript-dev-guide/widgets/widget_gallery.md

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -580,3 +580,56 @@ api.updateOptions([{
580580
[Fotorama widget]: http://fotorama.io/
581581
[lib/web/mage/gallery/gallery.js]: {{ site.mage2bloburl }}/{{ page.guide_version }}/lib/web/mage/gallery/gallery.js
582582
[lib/web/magnifier/magnify.js]: {{ site.mage2bloburl }}/{{ page.guide_version }}/lib/web/magnifier/magnify.js
583+
584+
## Code sample
585+
586+
This example shows a use case for a gallery widget on any page:
587+
588+
```html
589+
<div class="image-gallery"></div>
590+
591+
<script>
592+
require ([
593+
'jquery',
594+
'mage/gallery/gallery'
595+
], function ($, gallery) {
596+
$(function () {
597+
$('.image-gallery').each(function (index, element) {
598+
gallery({
599+
options: {
600+
"nav": "false",
601+
"loop": "true",
602+
"arrows": "true"
603+
},
604+
data: [
605+
{ img: "<image_url_1>" },
606+
{ img: "<image_url_2>" },
607+
{ img: "<image_url_3>" }
608+
],
609+
fullscreen: {
610+
"navdir": "horizontal"
611+
},
612+
"breakpoints": {
613+
"<breakpoint_name>": {
614+
"conditions": {
615+
"max-width": "767px"
616+
},
617+
"options": {}
618+
}
619+
}
620+
}, element);
621+
});
622+
});
623+
});
624+
</script>
625+
```
626+
627+
The breakpoints options are set in the `view.xml` configuration file of a theme. The file is located in `<theme_dir>/etc`.
628+
629+
```xml
630+
<var name="breakpoints">
631+
<var name="%breakpoints_option1%">%option1_value%</var>
632+
<var name="%breakpoints_option2%">%option2_value%</var>
633+
...
634+
</var>
635+
```

0 commit comments

Comments
 (0)