Merge branch 'master' of github.com:sveltejs/svelte

pull/2597/head
Richard Harris 6 years ago
commit 831926bccd

@ -573,10 +573,14 @@ component.$on(event, callback)
Causes the `callback` function to be called whenever the component dispatches an `event`. Causes the `callback` function to be called whenever the component dispatches an `event`.
A function is returned that will remove the event listener when called.
```js ```js
app.$on('selected', event => { const off = app.$on('selected', event => {
console.log(event.detail.selection); console.log(event.detail.selection);
}); });
off();
``` ```
#### `$destroy` #### `$destroy`

@ -2,7 +2,7 @@
title: This title: This
--- ---
The readonly `this` binding applies to every element (and component) and allows to you obtain a reference to rendered elements. For example, we can get a reference to a `<canvas>` element: The readonly `this` binding applies to every element (and component) and allows you to obtain a reference to rendered elements. For example, we can get a reference to a `<canvas>` element:
```html ```html
<canvas <canvas

@ -4,7 +4,7 @@ title: Local transitions
Ordinarily, transitions will play on elements when any container block is added or destroyed. In the example here, toggling the visibility of the entire list also applies transitions to individual list elements. Ordinarily, transitions will play on elements when any container block is added or destroyed. In the example here, toggling the visibility of the entire list also applies transitions to individual list elements.
Instead, we'd like transitions to play only when individual items are added and removed — on other words, when the user drags the slider. Instead, we'd like transitions to play only when individual items are added and removed — in other words, when the user drags the slider.
We can achieve this with a *local* transition, which only plays when the immediate parent block is added or removed: We can achieve this with a *local* transition, which only plays when the immediate parent block is added or removed:

@ -2,7 +2,7 @@
<html lang='en' class="theme-default typo-default"> <html lang='en' class="theme-default typo-default">
<head> <head>
<meta charset='utf-8'> <meta charset='utf-8'>
<meta name='viewport' content='width=device-width;initial-scale=1.0'> <meta name='viewport' content='width=device-width,initial-scale=1'>
<meta name='theme-color' content='#ff3e00'> <meta name='theme-color' content='#ff3e00'>
%sapper.base% %sapper.base%

Loading…
Cancel
Save