mirror of https://github.com/sveltejs/svelte
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
131 lines
3.1 KiB
131 lines
3.1 KiB
/* generated by Svelte vX.Y.Z */
|
|
import { appendNode, assign, blankObject, createComment, createElement, createText, detachNode, fixAndOutroAndDestroyBlock, fixPosition, init, insertNode, proto, updateKeyedEach, wrapAnimation } from "svelte/shared.js";
|
|
|
|
function foo(node, animation, params) {
|
|
const dx = animation.from.left - animation.to.left;
|
|
const dy = animation.from.top - animation.to.top;
|
|
|
|
return {
|
|
delay: params.delay,
|
|
duration: 100,
|
|
tick: (t, u) => {
|
|
node.dx = u * dx;
|
|
node.dy = u * dy;
|
|
}
|
|
};
|
|
};
|
|
|
|
function create_main_fragment(component, ctx) {
|
|
var each_blocks_1 = [], each_lookup = blankObject(), each_anchor;
|
|
|
|
var each_value = ctx.things;
|
|
|
|
const get_key = ctx => ctx.thing.id;
|
|
|
|
for (var i = 0; i < each_value.length; i += 1) {
|
|
let child_ctx = get_each_context(ctx, each_value, i);
|
|
let key = get_key(child_ctx);
|
|
each_blocks_1[i] = each_lookup[key] = create_each_block(component, key, child_ctx);
|
|
}
|
|
|
|
return {
|
|
c() {
|
|
for (i = 0; i < each_blocks_1.length; i += 1) each_blocks_1[i].c();
|
|
|
|
each_anchor = createComment();
|
|
},
|
|
|
|
m(target, anchor) {
|
|
for (i = 0; i < each_blocks_1.length; i += 1) each_blocks_1[i].m(target, anchor);
|
|
|
|
insertNode(each_anchor, target, anchor);
|
|
},
|
|
|
|
p(changed, ctx) {
|
|
const each_value = ctx.things;
|
|
for (let i = 0; i < each_blocks_1.length; i += 1) each_blocks_1[i].r();
|
|
each_blocks_1 = updateKeyedEach(each_blocks_1, component, changed, get_key, 1, ctx, each_value, each_lookup, each_anchor.parentNode, fixAndOutroAndDestroyBlock, create_each_block, "m", each_anchor, get_each_context);
|
|
for (let i = 0; i < each_blocks_1.length; i += 1) each_blocks_1[i].a();
|
|
},
|
|
|
|
d(detach) {
|
|
for (i = 0; i < each_blocks_1.length; i += 1) each_blocks_1[i].d(detach);
|
|
|
|
if (detach) {
|
|
detachNode(each_anchor);
|
|
}
|
|
}
|
|
};
|
|
}
|
|
|
|
// (1:0) {#each things as thing (thing.id)}
|
|
function create_each_block(component, key_1, ctx) {
|
|
var div, text_value = ctx.thing.name, text, rect, animation;
|
|
|
|
return {
|
|
key: key_1,
|
|
|
|
first: null,
|
|
|
|
c() {
|
|
div = createElement("div");
|
|
text = createText(text_value);
|
|
this.first = div;
|
|
},
|
|
|
|
m(target, anchor) {
|
|
insertNode(div, target, anchor);
|
|
appendNode(text, div);
|
|
},
|
|
|
|
p(changed, ctx) {
|
|
if ((changed.things) && text_value !== (text_value = ctx.thing.name)) {
|
|
text.data = text_value;
|
|
}
|
|
},
|
|
|
|
r() {
|
|
rect = div.getBoundingClientRect();
|
|
},
|
|
|
|
f() {
|
|
fixPosition(div);
|
|
if (animation) animation.stop();
|
|
},
|
|
|
|
a() {
|
|
if (animation) animation.stop();
|
|
animation = wrapAnimation(div, rect, foo, {});
|
|
},
|
|
|
|
d(detach) {
|
|
if (detach) {
|
|
detachNode(div);
|
|
}
|
|
}
|
|
};
|
|
}
|
|
|
|
function get_each_context(ctx, list, i) {
|
|
const child_ctx = Object.create(ctx);
|
|
child_ctx.thing = list[i];
|
|
child_ctx.each_value = list;
|
|
child_ctx.thing_index = i;
|
|
return child_ctx;
|
|
}
|
|
|
|
function SvelteComponent(options) {
|
|
init(this, options);
|
|
this._state = assign({}, options.data);
|
|
this._intro = true;
|
|
|
|
this._fragment = create_main_fragment(this, this._state);
|
|
|
|
if (options.target) {
|
|
this._fragment.c();
|
|
this._mount(options.target, options.anchor);
|
|
}
|
|
}
|
|
|
|
assign(SvelteComponent.prototype, proto);
|
|
export default SvelteComponent; |