Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

simpler code for case where there is only one outro in a block #1424

Merged
merged 1 commit into from
May 6, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/compile/dom/Block.ts
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ export default class Block {
${outroing} = true;
${hasIntros && `${introing} = false;`}

var #outros = ${this.outros};
${this.outros > 1 && `var #outros = ${this.outros};`}

${this.builders.outro}
},
Expand Down
16 changes: 8 additions & 8 deletions src/compile/nodes/Element.ts
Original file line number Diff line number Diff line change
Expand Up @@ -701,18 +701,18 @@ export default class Element extends Node {
const fn = `%transitions-${intro.name}`;

block.builders.intro.addBlock(deindent`
#component.root._aftercreate.push(function() {
#component.root._aftercreate.push(() => {
if (!${name}) ${name} = @wrapTransition(#component, ${this.var}, ${fn}, ${snippet}, true, null);
${name}.run(true, function() {
${name}.run(true, () => {
#component.fire("intro.end", { node: ${this.var} });
});
});
`);

block.builders.outro.addBlock(deindent`
${name}.run(false, function() {
${name}.run(false, () => {
#component.fire("outro.end", { node: ${this.var} });
if (--#outros === 0) #outrocallback();
${block.outros > 1 ? `if (--#outros === 0) #outrocallback();` : `#outrocallback();`}
${name} = null;
});
`);
Expand All @@ -736,9 +736,9 @@ export default class Element extends Node {
}

block.builders.intro.addBlock(deindent`
#component.root._aftercreate.push(function() {
#component.root._aftercreate.push(() => {
${introName} = @wrapTransition(#component, ${this.var}, ${fn}, ${snippet}, true, null);
${introName}.run(true, function() {
${introName}.run(true, () => {
#component.fire("intro.end", { node: ${this.var} });
});
});
Expand All @@ -757,9 +757,9 @@ export default class Element extends Node {
// group) prior to their removal from the DOM
block.builders.outro.addBlock(deindent`
${outroName} = @wrapTransition(#component, ${this.var}, ${fn}, ${snippet}, false, null);
${outroName}.run(false, function() {
${outroName}.run(false, () => {
#component.fire("outro.end", { node: ${this.var} });
if (--#outros === 0) #outrocallback();
${block.outros > 1 ? `if (--#outros === 0) #outrocallback();` : `#outrocallback();`}
});
`);
}
Expand Down