Skip to content

Commit

Permalink
Merge pull request #145 from IBEC-BOX/feat/gallery
Browse files Browse the repository at this point in the history
Feat/gallery
  • Loading branch information
Zh3nyaZh3nya authored Dec 11, 2024
2 parents 8b9cc08 + 2c25158 commit 87c16bd
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 20 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@ibecsystems/nuxt3-ui-kit",
"version": "1.0.58",
"version": "1.0.59",
"description": "Ibec Nuxt3 UI components",
"repository": {
"type": "git",
Expand Down
41 changes: 22 additions & 19 deletions src/runtime/components/Parts/Gallery/View.vue
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,9 @@ const { mdAndUp } = useDisplay()
const props = defineProps({
gallery: {
type: Array,
type: Object,
required: true,
default: () => [],
default: () => ({}),
},
previewImage: {
type: Object,
Expand All @@ -106,19 +106,7 @@ const emit = defineEmits(["update:modelValue"]);
const mainSwiperRef = ref();
const thumbsSwiperRef = ref();
const localGallery = ref([...props.gallery]);
function mainPrev() {
const swiper = mainSwiperRef.value.swiper;
swiper.slidePrev();
updateActiveImage(swiper.activeIndex);
}
function mainNext() {
const swiper = mainSwiperRef.value.swiper;
swiper.slideNext();
updateActiveImage(swiper.activeIndex);
}
const localGallery = ref(Object.values(props.gallery));
function setActiveImage(index) {
updateActiveImage(index);
Expand All @@ -133,8 +121,9 @@ function setActiveImage(index) {
}
function updateActiveImage(index) {
localGallery.value.forEach((img, idx) => {
img.active = idx === index;
const keys = Object.keys(props.gallery);
keys.forEach((key, idx) => {
props.gallery[key].active = idx === index;

Check failure on line 126 in src/runtime/components/Parts/Gallery/View.vue

View workflow job for this annotation

GitHub Actions / build

Unexpected mutation of "gallery" prop
});
if (thumbsSwiperRef.value?.swiper) {
Expand All @@ -143,6 +132,18 @@ function updateActiveImage(index) {
}
}
function mainPrev() {
const swiper = mainSwiperRef.value.swiper;
swiper.slidePrev();
updateActiveImage(swiper.activeIndex);
}
function mainNext() {
const swiper = mainSwiperRef.value.swiper;
swiper.slideNext();
updateActiveImage(swiper.activeIndex);
}
function onMainSlideChange() {
const activeIndex = mainSwiperRef.value.swiper.activeIndex;
updateActiveImage(activeIndex);
Expand All @@ -162,8 +163,10 @@ const localModelValue = computed({
});
onMounted(() => {
if(mdAndUp.value) {
localGallery.value.push({id: localGallery.value.length, image: '', active: false})
localGallery.value = Object.values(props.gallery);
if (mdAndUp.value) {
localGallery.value.push({ id: localGallery.value.length, image: '', active: false });
}
if (props.previewImage) {
Expand Down

0 comments on commit 87c16bd

Please sign in to comment.