Skip to content

Commit

Permalink
fix(svelte): swiperSlide slot data with context
Browse files Browse the repository at this point in the history
  • Loading branch information
nolimits4web committed Jan 25, 2022
1 parent b5c2d3b commit 89f14ab
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions src/svelte/swiper-slide.svelte
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<script>
import { onMount, onDestroy, beforeUpdate, afterUpdate, setContext } from 'svelte';
import { writable } from 'svelte/store';
import { onMount, onDestroy, beforeUpdate, afterUpdate, setContext, getContext } from 'svelte';
import { uniqueClasses } from './utils.js';
export let zoom = undefined;
Expand All @@ -12,7 +11,7 @@
let slideEl = null;
let slideClasses = 'swiper-slide';
let swiper = null;
let swiper = getContext('swiper');
let eventAttached = false;
const updateClasses = (_, el, classNames) => {
Expand All @@ -33,8 +32,7 @@
eventAttached = false;
};
const slideData = writable({});
$: slideData.set({
$: slideData = {
isActive:
slideClasses.indexOf('swiper-slide-active') >= 0 ||
slideClasses.indexOf('swiper-slide-duplicate-active') >= 0,
Expand All @@ -46,9 +44,7 @@
isNext:
slideClasses.indexOf('swiper-slide-next') >= 0 ||
slideClasses.indexOf('swiper-slide-duplicate-next') >= 0,
});
setContext('swiperSlide', slideData);
};
onMount(() => {
if (typeof virtualIndex === 'undefined') return;
Expand Down

0 comments on commit 89f14ab

Please sign in to comment.