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