• 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

68.35
/src/control/states/DraggingState.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 * as AXES from "../../const/axes";
5✔
9

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

12
/**
1✔
13
 * A state that activates when user's dragging the Flicking area
1✔
14
 * @ko 사용자가 드래깅중인 상태
1!
15
 * @internal
16
 */
17
class DraggingState extends State {
6!
18
  /**
×
19
   * Whether user is clicking or touching
20
   * @ko 현재 사용자가 클릭/터치중인지 여부
21
   * @type {true}
×
22
   * @readonly
23
   */
24
  public readonly holding = true;
3!
25
  /**
26
   * Whether Flicking's animating
27
   * @ko 현재 애니메이션 동작 여부
28
   * @type {true}
29
   * @readonly
1✔
30
   */
2!
31
  public readonly animating = true;
2✔
32

×
33
  public onChange(ctx: Parameters<State["onChange"]>[0]): void {
5✔
34
    this._moveToChangedPosition(ctx);
253✔
35
  }
36

1✔
37
  public onRelease(ctx: Parameters<State["onRelease"]>[0]) {
5✔
38
    const { flicking, axesEvent, transitTo } = ctx;
6✔
39

40
    // Update last position to cope with Axes's animating behavior
41
    // Axes uses start position when animation start
1✔
42
    flicking.trigger(new ComponentEvent(EVENTS.HOLD_END, {
3✔
43
      axesEvent
1✔
44
    }));
1✔
45

46
    if (flicking.renderer.panelCount <= 0) {
2!
47
      // There're no panels
48
      transitTo(STATE_TYPE.IDLE);
49
      return;
50
    }
1✔
51

1✔
52
    transitTo(STATE_TYPE.ANIMATING);
2✔
53

47✔
54
    const control = flicking.control;
2✔
55
    const position = axesEvent.destPos[AXES.POSITION_KEY];
2✔
56
    const duration = Math.max(axesEvent.duration, flicking.duration);
2✔
57

58
    try {
2✔
59
      void control.moveToPosition(position, duration, axesEvent);
2✔
60
    } catch (err) {
47✔
61
      transitTo(STATE_TYPE.IDLE);
62
      axesEvent.setTo({ [AXES.POSITION_KEY]: flicking.camera.position }, 0);
63
    }
64
  }
65
}
5✔
66

67
export default DraggingState;
52✔
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