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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
|
import { inject, injectable } from "tsyringe";
import OperatorFactoryChain from "../OperatorFactoryChain";
import ScrollPresenter from "../../presenters/ScrollPresenter";
import SettingRepository from "../../repositories/SettingRepository";
import * as operations from "../../../shared/operations";
import Operator from "../Operator";
import VerticalScrollOperator from "./VerticalScrollOperator";
import HorizontalScrollOperator from "./HorizontalScrollOperator";
import PageScrollOperator from "./PageScrollOperator";
import ScrollToTopOperator from "./ScrollToTopOperator";
import ScrollToBottomOperator from "./ScrollToBottomOperator";
import ScrollToHomeOperator from "./ScrollToHomeOperator";
import ScrollToEndOperator from "./ScrollToEndOperator";
@injectable()
export default class ScrollOperatorFactoryChain
implements OperatorFactoryChain
{
constructor(
@inject("ScrollPresenter")
private readonly scrollPresenter: ScrollPresenter,
@inject("SettingRepository")
private readonly settingRepository: SettingRepository
) {}
create(op: operations.Operation, repeat: number): Operator | null {
switch (op.type) {
case operations.SCROLL_VERTICALLY:
return new VerticalScrollOperator(
this.scrollPresenter,
this.settingRepository,
op.count * repeat
);
case operations.SCROLL_HORIZONALLY:
return new HorizontalScrollOperator(
this.scrollPresenter,
this.settingRepository,
op.count * repeat
);
case operations.SCROLL_PAGES:
return new PageScrollOperator(
this.scrollPresenter,
this.settingRepository,
op.count * repeat
);
case operations.SCROLL_TOP:
return new ScrollToTopOperator(
this.scrollPresenter,
this.settingRepository
);
case operations.SCROLL_BOTTOM:
return new ScrollToBottomOperator(
this.scrollPresenter,
this.settingRepository
);
case operations.SCROLL_HOME:
return new ScrollToHomeOperator(
this.scrollPresenter,
this.settingRepository
);
case operations.SCROLL_END:
return new ScrollToEndOperator(
this.scrollPresenter,
this.settingRepository
);
}
return null;
}
}
|