svelte-lazy-image
Advanced tools
Comparing version 0.0.1 to 0.0.2
42
index.js
@@ -12,18 +12,8 @@ (function (global, factory) { | ||
var img_levels = [ | ||
{ src: ctx.path }, | ||
{ alt: ctx.alt }, | ||
{ class: "svelte-lazy-image" }, | ||
ctx.$$props | ||
]; | ||
var img_data = {}; | ||
for (var i = 0; i < img_levels.length; i += 1) { | ||
img_data = internal.assign(img_data, img_levels[i]); | ||
} | ||
return { | ||
c() { | ||
img = internal.element("img"); | ||
internal.set_attributes(img, img_data); | ||
internal.attr(img, "src", ctx.path); | ||
internal.attr(img, "alt", ctx.alt); | ||
internal.attr(img, "class", "svelte-lazy-image"); | ||
internal.toggle_class(img, "svelte-lazy-image--loaded", ctx.loaded); | ||
@@ -39,9 +29,10 @@ dispose = internal.listen(img, "load", ctx.handleLoad); | ||
p(changed, ctx) { | ||
internal.set_attributes(img, internal.get_spread_update(img_levels, [ | ||
(changed.path) && { src: ctx.path }, | ||
(changed.alt) && { alt: ctx.alt }, | ||
{ class: "svelte-lazy-image" }, | ||
(changed.$$props) && ctx.$$props | ||
])); | ||
if (changed.path) { | ||
internal.attr(img, "src", ctx.path); | ||
} | ||
if (changed.alt) { | ||
internal.attr(img, "alt", ctx.alt); | ||
} | ||
if (changed.loaded) { | ||
@@ -105,7 +96,6 @@ internal.toggle_class(img, "svelte-lazy-image--loaded", ctx.loaded); | ||
$$self.$set = $$new_props => { | ||
$$invalidate('$$props', $$props = internal.assign(internal.assign({}, $$props), $$new_props)); | ||
if ('placeholder' in $$new_props) $$invalidate('placeholder', placeholder = $$new_props.placeholder); | ||
if ('src' in $$new_props) $$invalidate('src', src = $$new_props.src); | ||
if ('alt' in $$new_props) $$invalidate('alt', alt = $$new_props.alt); | ||
$$self.$set = $$props => { | ||
if ('placeholder' in $$props) $$invalidate('placeholder', placeholder = $$props.placeholder); | ||
if ('src' in $$props) $$invalidate('src', src = $$props.src); | ||
if ('alt' in $$props) $$invalidate('alt', alt = $$props.alt); | ||
}; | ||
@@ -127,5 +117,3 @@ | ||
handleLoad, | ||
$$props, | ||
img_binding, | ||
$$props: $$props = internal.exclude_internal_props($$props) | ||
img_binding | ||
}; | ||
@@ -132,0 +120,0 @@ } |
@@ -32,3 +32,3 @@ { | ||
], | ||
"version": "0.0.1" | ||
"version": "0.0.2" | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
8016
202