<template>
	<swiper class="image-container" previous-margin="140rpx" next-margin="140rpx" circular :autoplay="false" @change="swiperChange">
		<swiper-item :class="currentIndex == index ? 'swiper-item' : 'swiper-item-side'" v-for="(item, index) in imgList" :key="item[urlKey]">
			<image @click="clickImg(item)" :class="currentIndex == index ? 'item-img' : 'item-img-side'" :src="item[urlKey]" lazy-load :style="dontFirstAnimation ? 'animation: none;' : ''" mode="aspectFill"></image>
		</swiper-item>
	</swiper>
</template>
<script>
	export default {
		props: {
			imgList: {
				type: Array,
				default() {
					return []
				}
			},
			urlKey: {
				type: String,
				default() {
					return ''
				}
			},
		},
		data() {
			return {
				currentIndex: 0,
				dontFirstAnimation: true
			}
		},
		methods: {
			swiperChange(e) {
				this.dontFirstAnimation = false
				this.currentIndex = e.detail.current
				this.$emit('changeTicket', this.currentIndex)
			},
			clickImg(item) {
				this.$emit('selected', item, this.currentIndex)
			}
		}
	}
</script>
<style scoped>
	.image-container {
		width: 750rpx;
		height: 580rpx;
	}

	.item-img {
		width: 360rpx;
		height: 580rpx;
		animation: to-big .3s;
	}

	.swiper-item {
		width: 360rpx;
		height: 580rpx;
		display: flex;
		justify-content: center;
		align-items: center;
	}
	
	.item-img-side {
		width: 360rpx;
		height: 550rpx;
		animation: to-mini .3s;
	}

	.swiper-item-side {
		width: 360rpx;
		height: 550rpx;
		display: flex;
		justify-content: center;
		align-items: center;
	}
	@keyframes to-mini
	{
		from {
			height: 580rpx;
		}
		to {
			height: 550rpx;
		}
	}
	@keyframes to-big
	{
		from {
			height: 550rpx;
		}
		to {
			height: 580rpx;
		}
	}
</style>
