UNPKG

8.89 kBJavaScriptView Raw
1/* swiper.svelte generated by Svelte v3.31.2 */
2"use strict";
3
4const { SvelteComponent, assign, attr, binding_callbacks, check_outros, compute_rest_props, create_slot, detach, element, exclude_internal_props, get_spread_update, group_outros, init, insert, safe_not_equal, set_attributes, transition_in, transition_out, update_slot } = require("svelte/internal");
5const { onMount, onDestroy, beforeUpdate, afterUpdate, tick } = require("svelte");
6const { uniqueClasses } = require("./utils");
7const get_default_slot_changes_1 = dirty => ({ data: dirty & /*slideData*/ 32 });
8const get_default_slot_context_1 = ctx => ({ data: /*slideData*/ ctx[5] });
9const get_default_slot_changes = dirty => ({ data: dirty & /*slideData*/ 32 });
10const get_default_slot_context = ctx => ({ data: /*slideData*/ ctx[5] });
11
12// (92:2) {:else}
13function create_else_block(ctx) {
14 let current;
15 const default_slot_template = /*#slots*/ ctx[8].default;
16 const default_slot = create_slot(default_slot_template, ctx, /*$$scope*/ ctx[7], get_default_slot_context_1);
17
18 return {
19 c() {
20 if (default_slot) default_slot.c();
21 },
22 m(target, anchor) {
23 if (default_slot) {
24 default_slot.m(target, anchor);
25 }
26
27 current = true;
28 },
29 p(ctx, dirty) {
30 if (default_slot) {
31 if (default_slot.p && dirty & /*$$scope, slideData*/ 160) {
32 update_slot(default_slot, default_slot_template, ctx, /*$$scope*/ ctx[7], dirty, get_default_slot_changes_1, get_default_slot_context_1);
33 }
34 }
35 },
36 i(local) {
37 if (current) return;
38 transition_in(default_slot, local);
39 current = true;
40 },
41 o(local) {
42 transition_out(default_slot, local);
43 current = false;
44 },
45 d(detaching) {
46 if (default_slot) default_slot.d(detaching);
47 }
48 };
49}
50
51// (85:2) {#if zoom}
52function create_if_block(ctx) {
53 let div;
54 let div_data_swiper_zoom_value;
55 let current;
56 const default_slot_template = /*#slots*/ ctx[8].default;
57 const default_slot = create_slot(default_slot_template, ctx, /*$$scope*/ ctx[7], get_default_slot_context);
58
59 return {
60 c() {
61 div = element("div");
62 if (default_slot) default_slot.c();
63 attr(div, "class", "swiper-zoom-container");
64
65 attr(div, "data-swiper-zoom", div_data_swiper_zoom_value = typeof /*zoom*/ ctx[0] === "number"
66 ? /*zoom*/ ctx[0]
67 : undefined);
68 },
69 m(target, anchor) {
70 insert(target, div, anchor);
71
72 if (default_slot) {
73 default_slot.m(div, null);
74 }
75
76 current = true;
77 },
78 p(ctx, dirty) {
79 if (default_slot) {
80 if (default_slot.p && dirty & /*$$scope, slideData*/ 160) {
81 update_slot(default_slot, default_slot_template, ctx, /*$$scope*/ ctx[7], dirty, get_default_slot_changes, get_default_slot_context);
82 }
83 }
84
85 if (!current || dirty & /*zoom*/ 1 && div_data_swiper_zoom_value !== (div_data_swiper_zoom_value = typeof /*zoom*/ ctx[0] === "number"
86 ? /*zoom*/ ctx[0]
87 : undefined)) {
88 attr(div, "data-swiper-zoom", div_data_swiper_zoom_value);
89 }
90 },
91 i(local) {
92 if (current) return;
93 transition_in(default_slot, local);
94 current = true;
95 },
96 o(local) {
97 transition_out(default_slot, local);
98 current = false;
99 },
100 d(detaching) {
101 if (detaching) detach(div);
102 if (default_slot) default_slot.d(detaching);
103 }
104 };
105}
106
107function create_fragment(ctx) {
108 let div;
109 let current_block_type_index;
110 let if_block;
111 let div_class_value;
112 let current;
113 const if_block_creators = [create_if_block, create_else_block];
114 const if_blocks = [];
115
116 function select_block_type(ctx, dirty) {
117 if (/*zoom*/ ctx[0]) return 0;
118 return 1;
119 }
120
121 current_block_type_index = select_block_type(ctx, -1);
122 if_block = if_blocks[current_block_type_index] = if_block_creators[current_block_type_index](ctx);
123
124 let div_levels = [
125 {
126 class: div_class_value = uniqueClasses(`${/*slideClasses*/ ctx[3]}${/*className*/ ctx[2] ? ` ${/*className*/ ctx[2]}` : ""}`)
127 },
128 {
129 "data-swiper-slide-index": /*virtualIndex*/ ctx[1]
130 },
131 /*$$restProps*/ ctx[6]
132 ];
133
134 let div_data = {};
135
136 for (let i = 0; i < div_levels.length; i += 1) {
137 div_data = assign(div_data, div_levels[i]);
138 }
139
140 return {
141 c() {
142 div = element("div");
143 if_block.c();
144 set_attributes(div, div_data);
145 },
146 m(target, anchor) {
147 insert(target, div, anchor);
148 if_blocks[current_block_type_index].m(div, null);
149 /*div_binding*/ ctx[9](div);
150 current = true;
151 },
152 p(ctx, [dirty]) {
153 let previous_block_index = current_block_type_index;
154 current_block_type_index = select_block_type(ctx, dirty);
155
156 if (current_block_type_index === previous_block_index) {
157 if_blocks[current_block_type_index].p(ctx, dirty);
158 } else {
159 group_outros();
160
161 transition_out(if_blocks[previous_block_index], 1, 1, () => {
162 if_blocks[previous_block_index] = null;
163 });
164
165 check_outros();
166 if_block = if_blocks[current_block_type_index];
167
168 if (!if_block) {
169 if_block = if_blocks[current_block_type_index] = if_block_creators[current_block_type_index](ctx);
170 if_block.c();
171 } else {
172 if_block.p(ctx, dirty);
173 }
174
175 transition_in(if_block, 1);
176 if_block.m(div, null);
177 }
178
179 set_attributes(div, div_data = get_spread_update(div_levels, [
180 (!current || dirty & /*slideClasses, className*/ 12 && div_class_value !== (div_class_value = uniqueClasses(`${/*slideClasses*/ ctx[3]}${/*className*/ ctx[2] ? ` ${/*className*/ ctx[2]}` : ""}`))) && { class: div_class_value },
181 (!current || dirty & /*virtualIndex*/ 2) && {
182 "data-swiper-slide-index": /*virtualIndex*/ ctx[1]
183 },
184 dirty & /*$$restProps*/ 64 && /*$$restProps*/ ctx[6]
185 ]));
186 },
187 i(local) {
188 if (current) return;
189 transition_in(if_block);
190 current = true;
191 },
192 o(local) {
193 transition_out(if_block);
194 current = false;
195 },
196 d(detaching) {
197 if (detaching) detach(div);
198 if_blocks[current_block_type_index].d();
199 /*div_binding*/ ctx[9](null);
200 }
201 };
202}
203
204function instance($$self, $$props, $$invalidate) {
205 let slideData;
206 const omit_props_names = ["zoom","virtualIndex","class"];
207 let $$restProps = compute_rest_props($$props, omit_props_names);
208 let { $$slots: slots = {}, $$scope } = $$props;
209 let { zoom = undefined } = $$props;
210 let { virtualIndex = undefined } = $$props;
211 let { class: className = undefined } = $$props;
212 let slideEl = null;
213 let slideClasses = "swiper-slide";
214 let swiper = null;
215 let eventAttached = false;
216
217 const updateClasses = (_, el, classNames) => {
218 if (el === slideEl) {
219 $$invalidate(3, slideClasses = classNames);
220 }
221 };
222
223 const attachEvent = () => {
224 if (!swiper || eventAttached) return;
225 swiper.on("_slideClass", updateClasses);
226 eventAttached = true;
227 };
228
229 const detachEvent = () => {
230 if (!swiper) return;
231 swiper.off("_slideClass", updateClasses);
232 eventAttached = false;
233 };
234
235 onMount(() => {
236 if (typeof virtualIndex === "undefined") return;
237
238 $$invalidate(
239 4,
240 slideEl.onSwiper = _swiper => {
241 swiper = _swiper;
242 attachEvent();
243 },
244 slideEl
245 );
246
247 attachEvent();
248 });
249
250 afterUpdate(() => {
251 if (!slideEl || !swiper) return;
252
253 if (swiper.destroyed) {
254 if (slideClasses !== "swiper-slide") {
255 $$invalidate(3, slideClasses = "swiper-slide");
256 }
257
258 return;
259 }
260
261 attachEvent();
262 });
263
264 beforeUpdate(() => {
265 attachEvent();
266 });
267
268 onDestroy(() => {
269 if (!swiper) return;
270 detachEvent();
271 });
272
273 function div_binding($$value) {
274 binding_callbacks[$$value ? "unshift" : "push"](() => {
275 slideEl = $$value;
276 $$invalidate(4, slideEl);
277 });
278 }
279
280 $$self.$$set = $$new_props => {
281 $$props = assign(assign({}, $$props), exclude_internal_props($$new_props));
282 $$invalidate(6, $$restProps = compute_rest_props($$props, omit_props_names));
283 if ("zoom" in $$new_props) $$invalidate(0, zoom = $$new_props.zoom);
284 if ("virtualIndex" in $$new_props) $$invalidate(1, virtualIndex = $$new_props.virtualIndex);
285 if ("class" in $$new_props) $$invalidate(2, className = $$new_props.class);
286 if ("$$scope" in $$new_props) $$invalidate(7, $$scope = $$new_props.$$scope);
287 };
288
289 $$self.$$.update = () => {
290 if ($$self.$$.dirty & /*slideClasses*/ 8) {
291 $: $$invalidate(5, slideData = {
292 isActive: slideClasses.indexOf("swiper-slide-active") >= 0 || slideClasses.indexOf("swiper-slide-duplicate-active") >= 0,
293 isVisible: slideClasses.indexOf("swiper-slide-visible") >= 0,
294 isDuplicate: slideClasses.indexOf("swiper-slide-duplicate") >= 0,
295 isPrev: slideClasses.indexOf("swiper-slide-prev") >= 0 || slideClasses.indexOf("swiper-slide-duplicate-prev") >= 0,
296 isNext: slideClasses.indexOf("swiper-slide-next") >= 0 || slideClasses.indexOf("swiper-slide-duplicate-next") >= 0
297 });
298 }
299 };
300
301 return [
302 zoom,
303 virtualIndex,
304 className,
305 slideClasses,
306 slideEl,
307 slideData,
308 $$restProps,
309 $$scope,
310 slots,
311 div_binding
312 ];
313}
314
315class Swiper extends SvelteComponent {
316 constructor(options) {
317 super();
318 init(this, options, instance, create_fragment, safe_not_equal, { zoom: 0, virtualIndex: 1, class: 2 });
319 }
320}
321
322exports.default = Swiper;
\No newline at end of file