You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We had a lot of issues imposing our desires to the gallery, so maybe, in the end, we ended up with very crooked code.
Basically we have a gallery a thumbs linked to that gallery.
We wanted each thumb to be equally in size and next we want there to be a default distance between each thumb. When you switch to a smaller screen, you'll have less thumbs, but they remain 100px by 100px boxes with 25px space in between.
We tried to define the thumb-swiper in the constructor or onInit or afterViewInit with breakpoints, but the swiper doesn't respond to it at all.
I think the way we link the gallery with the thumbs is wrong, but we can't get it to work in any other way. We're now triggering the link with an event, it seems. There should be a way to pass the breakpoints-data when establishing the link somehow.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
We had a lot of issues imposing our desires to the gallery, so maybe, in the end, we ended up with very crooked code.
Basically we have a gallery a thumbs linked to that gallery.
We wanted each thumb to be equally in size and next we want there to be a default distance between each thumb. When you switch to a smaller screen, you'll have less thumbs, but they remain 100px by 100px boxes with 25px space in between.
We tried to define the thumb-swiper in the constructor or onInit or afterViewInit with breakpoints, but the swiper doesn't respond to it at all.
I think the way we link the gallery with the thumbs is wrong, but we can't get it to work in any other way. We're now triggering the link with an event, it seems. There should be a way to pass the breakpoints-data when establishing the link somehow.
https://stackoverflow.com/questions/67967158/angular2-swiperjs-unable-to-impose-spacebetween-or-breakpoints-in-a-gallery-o
Any suggestions, ideas, links, ..., are more than welcome.
code
html
`
<swiper (slideChange)="onSlideChange($event)" [navigation]="true" [slidesPerView]="1" [spaceBetween]="100" [thumbs]="{ swiper: thumbSwiper }" [centeredSlides]="true">
<ng-template swiperSlide *ngFor="let data of dataCarousel">
<img [src]="data.photoUrl" loading="lazy">
<swiper class="thumbSwiper"
(swiper)="setThumbSwiper($event)"
[navigation]="{}"
[scrollbar]="{ draggable: true }"
>
<ng-template swiperSlide *ngFor="let data of dataCarousel">
<img class="text-center imgthumb" [src]="data.thumbUrl" loading="lazy">
`
css
`
html, body {
position: relative;
}
body {
font-family: Helvetica Neue, Helvetica, Arial, sans-serif;
font-size: 14px;
color: #000;
margin: 0;
padding: 0;
}
.swiper-slide {
background-size: auto;
background-position: center;
}
.gallery-top {
height: 80%;
width: 100%;
}
.gallery-thumbs {
height: 20%;
box-sizing: border-box;
}
.gallery-thumbs .swiper-slide {
width: 25%;
height: 100px;
width: 100px;
opacity: 0.4;
}
.gallery-thumbs .swiper-slide-thumb-active {
opacity: 1;
}
.swiper-container {
width: auto;
height: auto;
margin-left: auto;
margin-right: auto;
}
img {
text-align: center;
height: 100%;
width: auto;
}
.swiper-container .customcontainer {
max-width: 100px;
min-width: 100px;
max-height: 100px;
min-height: 100px;
overflow: hidden;
}
.imgthumb {
text-align: center;
}
`
typescript
`
import { AfterViewInit, Component, EventEmitter, Input, OnInit, Output } from "@angular/core";
import SwiperCore, { Navigation, Pagination, Scrollbar, A11y, Virtual, Zoom, Autoplay, Thumbs, Controller, Swiper } from 'swiper/core';
SwiperCore.use([Navigation, Pagination, Scrollbar, A11y, Virtual, Zoom, Autoplay, Thumbs, Controller]);
import { Carouselobject } from "../../helperclasses/Carouselobject";
@component({
templateUrl: './carousel.component.html',
styleUrls: ['./carousel.component.scss'],
selector: 'carousel'
})
export class CarouselComponent implements AfterViewInit {
}
`
Beta Was this translation helpful? Give feedback.
All reactions