-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.ts
42 lines (34 loc) · 970 Bytes
/
main.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import { Observable } from 'rxjs';
/*let numbers = [1, 6, 10]
let source = Observable.create(observer => {
let index = 0;
let getValue = () => {
observer.next(numbers[index++]);
if (index < numbers.length) {
setTimeout(getValue, 2500)
}
else {
observer.complete();
}
}
getValue();
})*/
let round = document.getElementById("round");
let source = Observable.fromEvent(document,"mousemove")
.map((e:MouseEvent)=>{
return {
x:e.clientX,
y:e.clientY
}
})
.filter(value=> value.x<500)
.delay(500)
function onNext(value){
round.style.left = value.x;
round.style.top = value.y;
}
source.subscribe(
onNext,
e => console.log(`error ${e}`),
() => console.log("completed")
)