• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

naver / egjs-flicking / 4550193631

pending completion
4550193631

Pull #794

github

GitHub
Merge f8b6de8d9 into 761aa929d
Pull Request #794: docs: fix misspelled path in document

4448 of 7210 branches covered (61.69%)

Branch coverage included in aggregate %.

8413 of 9000 relevant lines covered (93.48%)

142.07 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

67.78
/src/control/states/IdleState.ts
1
/*
1✔
2
 * Copyright (c) 2015 NAVER Corp.
1✔
3
 * egjs projects are licensed under the MIT license
1✔
4
 */
1!
5
import { ComponentEvent } from "@egjs/component";
5✔
6

×
7
import { EVENTS } from "../../const/external";
6✔
8
import { getDirection } from "../../utils";
5✔
9

1✔
10
import State, { STATE_TYPE } from "./State";
6!
11

12
/**
1✔
13
 * A default state when there's no user input and no animation's playing
1✔
14
 * @ko 사용자의 입력이 없고, 애니메이션이 동작하고있지 않은 기본 상태
1!
15
 * @internal
16
 */
17
class IdleState extends State {
18!
18
  /**
×
19
   * Whether user is clicking or touching
20
   * @ko 현재 사용자가 클릭/터치중인지 여부
21
   * @type {false}
×
22
   * @readonly
23
   */
24
  public readonly holding = false;
18!
25
  /**
26
   * Whether Flicking's animating
27
   * @ko 현재 애니메이션 동작 여부
28
   * @type {false}
29
   * @readonly
1✔
30
   */
1!
31
  public readonly animating = false;
17✔
32

×
33
  public onEnter() {
5✔
34
    this._delta = 0;
3✔
35
    this._targetPanel = null;
3✔
36
  }
1✔
37

38
  public onHold(ctx: Parameters<State["onHold"]>[0]): void {
5✔
39
    // Shouldn't do any action until any panels on flicking area
40
    const { flicking, axesEvent, transitTo } = ctx;
9✔
41

1✔
42
    if (flicking.renderer.panelCount <= 0) {
4!
43
      transitTo(STATE_TYPE.DISABLED);
1✔
44
      return;
1✔
45
    }
46

47
    const holdStartEvent = new ComponentEvent(EVENTS.HOLD_START, {
3✔
48
      axesEvent
49
    });
50

1✔
51
    flicking.trigger(holdStartEvent);
4✔
52

53
    if (holdStartEvent.isCanceled()) {
596!
54
      transitTo(STATE_TYPE.DISABLED);
55
    } else {
56
      transitTo(STATE_TYPE.HOLDING);
3✔
57
    }
58
  }
59

60
  // By methods call
593✔
61
  public onChange(ctx: Parameters<State["onChange"]>[0]): void {
5✔
62
    const { flicking, axesEvent, transitTo } = ctx;
6✔
63
    const controller = flicking.control.controller;
2✔
64
    const animatingContext = controller.animatingContext;
2✔
65

66
    const moveStartEvent = new ComponentEvent(EVENTS.MOVE_START, {
2✔
67
      isTrusted: axesEvent.isTrusted,
593✔
68
      holding: this.holding,
593✔
69
      direction: getDirection(animatingContext.start, animatingContext.end),
70
      axesEvent
1✔
71
    });
105✔
72
    flicking.trigger(moveStartEvent);
107✔
73

74
    if (moveStartEvent.isCanceled()) {
3!
75
      transitTo(STATE_TYPE.DISABLED);
76
    } else {
46✔
77
      // Trigger AnimatingState's onChange, to trigger "move" event immediately
46!
78
      transitTo(STATE_TYPE.ANIMATING).onChange(ctx);
2✔
79
    }
80
  }
81
}
51✔
82

83
export default IdleState;
5✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc