Skip to content

Commit

Permalink
site: actions tutorial: destroy is not required (#2776)
Browse files Browse the repository at this point in the history
  • Loading branch information
Conduitry committed May 24, 2019
1 parent a6c05ed commit 2f80667
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions site/content/tutorial/12-actions/01-actions/text.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import { pannable } from './pannable.js';
></div>
```

Open the `pannable.js` file. Like transition functions, an action function receives a `node` and some optional parameters, and returns an action object. That object must have a `destroy` function, which is called when the element is unmounted.
Open the `pannable.js` file. Like transition functions, an action function receives a `node` and some optional parameters, and returns an action object. That object can have a `destroy` function, which is called when the element is unmounted.

We want to fire `panstart` event when the user mouses down on the element, `panmove` events (with `dx` and `dy` properties showing how far the mouse moved) when they drag it, and `panend` events when they mouse up. One possible implementation looks like this:

Expand Down Expand Up @@ -84,4 +84,3 @@ export function pannable(node) {
Update the `pannable` function and try moving the box around.

> This implementation is for demonstration purposes — a more complete one would also consider touch events.

0 comments on commit 2f80667

Please sign in to comment.