Skip to content

Commit 72de31e

Browse files
committed
Use non-trivial selector for horizontal example
1 parent 0093a78 commit 72de31e

File tree

3 files changed

+23
-26
lines changed

3 files changed

+23
-26
lines changed

README.md

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,6 @@ NPM: https://www.npmjs.com/package/cyclejs-sortable
1212
You can check out live versions of the [examples](./examples/) here:
1313
- [simple](./examples/simple/src/index.ts): https://cyclejs-community.github.io/cyclejs-sortable/examples/simple/
1414
- [horizontal](./examples/horizontal/src/index.ts): https://cyclejs-community.github.io/cyclejs-sortable/examples/horizontal/
15-
- [parentSelector](./examples/parentSelector/src/index.ts): https://cyclejs-community.github.io/cyclejs-sortable/examples/parentSelector/
16-
- [updateEvent](./examples/updateEvent/src/index.ts): https://cyclejs-community.github.io/cyclejs-sortable/examples/updateEvent/
17-
18-
## Required Polyfills
19-
The code uses a few ES6 features, so you might need an es6 polyfill like `babel-polyfill`
20-
21-
The use the `updateOrder Event` in IE you have to add a CustomEvent constructor polyfill like https://www.npmjs.com/package/custom-event
2215

2316
## Installation
2417

@@ -28,16 +21,20 @@ The use the `updateOrder Event` in IE you have to add a CustomEvent constructor
2821
For more information see the [examples](https://github.com/SuperManitu/cyclejs-sortable/tree/master/examples)
2922

3023
```
31-
function main(sources)
24+
const main = isolate(
25+
makeSortable(Component, { itemSelector: 'div > div' }),
26+
'myScope'
27+
);
28+
29+
function Component(sources)
3230
{
3331
return {
3432
DOM: xs.of(div([
3533
div(['one']),
3634
div(['two']),
3735
div(['three']),
3836
div(['four'])
39-
]))
40-
.compose(makeSortable(sources.DOM))
37+
]));
4138
}
4239
}
4340
```

examples/horizontal/src/index.ts

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,14 @@ import {
1313

1414
import { makeSortable } from '../../../src/makeSortable';
1515

16-
type Sources = {
16+
interface Sources {
1717
DOM: DOMSource;
18-
};
18+
}
1919

20-
type Sinks = {
20+
interface Sinks {
2121
DOM?: Observable<VNode>;
22-
sortable?: Observable<boolean>;
23-
};
22+
drag?: Observable<boolean>;
23+
}
2424

2525
function userSelectDriver(sort$): void {
2626
sort$.addListener({
@@ -40,11 +40,11 @@ function userSelectDriver(sort$): void {
4040

4141
function main(sources: Sources): Sinks {
4242
const sinks = makeSortable(Child, {
43-
itemSelector: '.li'
43+
itemSelector: 'ul > li'
4444
})(sources);
4545

4646
return {
47-
...sinks,
47+
drag: sinks.drag,
4848
DOM: sinks.DOM.map(dom =>
4949
div([h3('Horizontal too!'), p('this is running with RxJS'), dom])
5050
)
@@ -53,13 +53,13 @@ function main(sources: Sources): Sinks {
5353

5454
function Child({ DOM }: Sources): Sinks {
5555
const vdom$: Observable<VNode> = Observable.of(
56-
ul('.ul', [
57-
li('.li', '', ['Option 1']),
58-
li('.li', '', ['Option 2']),
59-
li('.li', '', ['Option 3']),
60-
li('.li', '', ['Option 4']),
61-
li('.li', '', ['Option 5']),
62-
li('.li', '', ['Option 6'])
56+
ul([
57+
li(['Option 1']),
58+
li(['Option 2']),
59+
li(['Option 3']),
60+
li(['Option 4']),
61+
li(['Option 5']),
62+
li(['Option 6'])
6363
])
6464
);
6565

@@ -70,5 +70,5 @@ function Child({ DOM }: Sources): Sinks {
7070

7171
run(main, {
7272
DOM: makeDOMDriver('#app'),
73-
sortable: userSelectDriver
73+
drag: userSelectDriver
7474
});

src/makeSortable.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ export function makeSortable(
9696
return {
9797
...sinks,
9898
DOM: adapt(vdom$),
99-
sortable: adapt(dragInProgress$)
99+
drag: adapt(dragInProgress$)
100100
};
101101
};
102102
}

0 commit comments

Comments
 (0)