vevet 2.0.1-dev.2 → 2.0.1-dev.23

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (96) hide show
  1. package/build/cdn/index.js +1 -1
  2. package/build/cjs/components/canvas/Ctx2DPrerender.js +20 -2
  3. package/build/cjs/components/loading/ProgressPreloader.js +14 -2
  4. package/build/cjs/components/page/Page.js +36 -8
  5. package/build/cjs/components/scroll/plugins/SmoothScrollDragPlugin.js +40 -5
  6. package/build/cjs/components/scroll/plugins/SmoothScrollKeyboardPlugin.js +9 -0
  7. package/build/cjs/components/scroll/scrollable/ScrollView.js +80 -53
  8. package/build/cjs/components/scroll/scrollbar/Bar.js +8 -2
  9. package/build/cjs/components/scroll/smooth-scroll/SmoothScroll.js +11 -3
  10. package/build/cjs/components/text/SplitText.js +19 -3
  11. package/build/cjs/components/timeline/Timeline.js +1 -0
  12. package/build/cjs/handlers/wheel/WheelHandler.js +195 -0
  13. package/build/cjs/index.js +3 -1
  14. package/build/cjs/utils/listeners/onScroll.js +65 -25
  15. package/build/cjs/utils/math/index.js +5 -1
  16. package/build/cjs/utils/math/spreadScopeProgress.js +18 -0
  17. package/build/cjs/utils/math/wrap.js +13 -0
  18. package/build/es/app/Application.js +50 -93
  19. package/build/es/app/events/PageLoad.js +3 -7
  20. package/build/es/app/events/Viewport.js +10 -34
  21. package/build/es/base/Callbacks.js +8 -19
  22. package/build/es/base/Component.js +0 -1
  23. package/build/es/base/Module.js +41 -61
  24. package/build/es/base/MutableProp.js +10 -32
  25. package/build/es/base/Plugin.js +0 -1
  26. package/build/es/components/animation-frame/AnimationFrame.js +4 -28
  27. package/build/es/components/canvas/Ctx2D.js +21 -49
  28. package/build/es/components/canvas/Ctx2DPrerender.js +21 -7
  29. package/build/es/components/cursor/CustomCursor.js +25 -58
  30. package/build/es/components/dragger/Dragger.js +20 -41
  31. package/build/es/components/dragger/DraggerDirection.js +1 -4
  32. package/build/es/components/loading/Preloader.js +26 -41
  33. package/build/es/components/loading/ProgressPreloader.js +31 -38
  34. package/build/es/components/page/Page.js +46 -41
  35. package/build/es/components/scroll/plugins/SmoothScrollDragPlugin.js +47 -29
  36. package/build/es/components/scroll/plugins/SmoothScrollKeyboardPlugin.js +9 -0
  37. package/build/es/components/scroll/scrollable/ScrollEventsBase.js +15 -22
  38. package/build/es/components/scroll/scrollable/ScrollView.js +74 -74
  39. package/build/es/components/scroll/scrollbar/Bar.js +43 -54
  40. package/build/es/components/scroll/scrollbar/ScrollBar.js +47 -73
  41. package/build/es/components/scroll/smooth-scroll/SmoothScroll.js +63 -135
  42. package/build/es/components/text/SplitText.js +39 -44
  43. package/build/es/components/timeline/StaticTimeline.js +11 -22
  44. package/build/es/components/timeline/Timeline.js +13 -28
  45. package/build/es/handlers/wheel/WheelHandler.js +153 -0
  46. package/build/es/index.js +2 -1
  47. package/build/es/utils/listeners/onScroll.js +64 -25
  48. package/build/es/utils/math/index.js +3 -1
  49. package/build/es/utils/math/spreadScopeProgress.js +15 -0
  50. package/build/es/utils/math/wrap.js +10 -0
  51. package/build/types/components/canvas/Ctx2DPrerender.d.ts +1 -1
  52. package/build/types/components/canvas/Ctx2DPrerender.d.ts.map +1 -1
  53. package/build/types/components/loading/ProgressPreloader.d.ts +7 -0
  54. package/build/types/components/loading/ProgressPreloader.d.ts.map +1 -1
  55. package/build/types/components/page/Page.d.ts +2 -0
  56. package/build/types/components/page/Page.d.ts.map +1 -1
  57. package/build/types/components/scroll/plugins/SmoothScrollDragPlugin.d.ts +11 -0
  58. package/build/types/components/scroll/plugins/SmoothScrollDragPlugin.d.ts.map +1 -1
  59. package/build/types/components/scroll/plugins/SmoothScrollKeyboardPlugin.d.ts.map +1 -1
  60. package/build/types/components/scroll/scrollable/ScrollView.d.ts +27 -13
  61. package/build/types/components/scroll/scrollable/ScrollView.d.ts.map +1 -1
  62. package/build/types/components/scroll/scrollbar/Bar.d.ts.map +1 -1
  63. package/build/types/components/scroll/smooth-scroll/SmoothScroll.d.ts.map +1 -1
  64. package/build/types/components/text/SplitText.d.ts +6 -0
  65. package/build/types/components/text/SplitText.d.ts.map +1 -1
  66. package/build/types/components/timeline/Timeline.d.ts.map +1 -1
  67. package/build/types/handlers/wheel/WheelHandler.d.ts +100 -0
  68. package/build/types/handlers/wheel/WheelHandler.d.ts.map +1 -0
  69. package/build/types/index.d.ts +2 -1
  70. package/build/types/index.d.ts.map +1 -1
  71. package/build/types/utils/listeners/onScroll.d.ts +13 -5
  72. package/build/types/utils/listeners/onScroll.d.ts.map +1 -1
  73. package/build/types/utils/math/index.d.ts +3 -1
  74. package/build/types/utils/math/index.d.ts.map +1 -1
  75. package/build/types/utils/math/spreadScopeProgress.d.ts +5 -0
  76. package/build/types/utils/math/spreadScopeProgress.d.ts.map +1 -0
  77. package/build/types/utils/math/wrap.d.ts +5 -0
  78. package/build/types/utils/math/wrap.d.ts.map +1 -0
  79. package/package.json +4 -3
  80. package/src/sass/components/cursor/_custom-cursor.scss +0 -1
  81. package/src/ts/components/canvas/Ctx2DPrerender.ts +23 -6
  82. package/src/ts/components/loading/ProgressPreloader.ts +21 -2
  83. package/src/ts/components/page/Page.ts +34 -8
  84. package/src/ts/components/scroll/plugins/SmoothScrollDragPlugin.ts +58 -5
  85. package/src/ts/components/scroll/plugins/SmoothScrollKeyboardPlugin.ts +12 -0
  86. package/src/ts/components/scroll/scrollable/ScrollView.ts +90 -64
  87. package/src/ts/components/scroll/scrollbar/Bar.ts +8 -2
  88. package/src/ts/components/scroll/smooth-scroll/SmoothScroll.ts +12 -3
  89. package/src/ts/components/text/SplitText.ts +27 -2
  90. package/src/ts/components/timeline/Timeline.ts +1 -0
  91. package/src/ts/handlers/wheel/WheelHandler.ts +269 -0
  92. package/src/ts/index.ts +4 -0
  93. package/src/ts/utils/listeners/onScroll.ts +105 -34
  94. package/src/ts/utils/math/index.ts +4 -0
  95. package/src/ts/utils/math/spreadScopeProgress.ts +18 -0
  96. package/src/ts/utils/math/wrap.ts +18 -0
@@ -3,20 +3,6 @@ import { timeoutCallback, randID } from '../utils/common';
3
3
  * A class for callbacks' manipulation.
4
4
  */
5
5
  export class Callbacks {
6
- /**
7
- * Vevet Application
8
- */
9
- _app;
10
- /**
11
- * All callbacks
12
- */
13
- _callbacks;
14
- /**
15
- * Get all callbacks
16
- */
17
- get callbacks() {
18
- return this._callbacks;
19
- }
20
6
  /**
21
7
  * @example
22
8
  * const callback = new Callbacks();
@@ -29,6 +15,12 @@ export class Callbacks {
29
15
  this._init();
30
16
  }
31
17
  }
18
+ /**
19
+ * Get all callbacks
20
+ */
21
+ get callbacks() {
22
+ return this._callbacks;
23
+ }
32
24
  /**
33
25
  * Initialize the class.
34
26
  */
@@ -64,12 +56,9 @@ export class Callbacks {
64
56
  const obj = {
65
57
  id,
66
58
  on: true,
67
- data: {
68
- target,
59
+ data: Object.assign({ target,
69
60
  // @ts-ignore
70
- do: func,
71
- ...data,
72
- },
61
+ do: func }, data),
73
62
  };
74
63
  this._callbacks.push(obj);
75
64
  this._onAdd(id);
@@ -3,7 +3,6 @@ import { Module } from './Module';
3
3
  * A class for Components.
4
4
  */
5
5
  export class Component extends Module {
6
- _plugins;
7
6
  /**
8
7
  * Add a single plugin
9
8
  */
@@ -7,6 +7,47 @@ import { throwVevetAppError } from '../utils/errors';
7
7
  * A class for modules.
8
8
  */
9
9
  export class Module {
10
+ /**
11
+ * @example
12
+ * const mod = new Module();
13
+ */
14
+ constructor(
15
+ /**
16
+ * Properties on script start
17
+ */
18
+ initialProp,
19
+ /**
20
+ * Defines if you need to call {@linkcode Module.init} at the constructor's end.
21
+ * If you want to add responsive properties, set this argument to FALSE.
22
+ */
23
+ init = true) {
24
+ /**
25
+ * If the module is initialized
26
+ */
27
+ this._inited = false;
28
+ /**
29
+ * Viewport callbacks
30
+ */
31
+ this._viewportCallbacks = [];
32
+ // set vars
33
+ if (window.vevetApp) {
34
+ this._app = window.vevetApp;
35
+ }
36
+ else {
37
+ throwVevetAppError();
38
+ }
39
+ // set default vars
40
+ this._destroyed = false;
41
+ this._listeners = [];
42
+ // create callbacks
43
+ this._callbacks = new Callbacks();
44
+ // create mutable properties
45
+ const prop = mergeWithoutArrays(this._getDefaultProp(), initialProp || {});
46
+ this._mutableProp = new MutableProp(prop, this._onPropResponsive.bind(this), this._onPropChange.bind(this), this.name);
47
+ if (init) {
48
+ this.init();
49
+ }
50
+ }
10
51
  /**
11
52
  * Get Default properties (should be extended)
12
53
  */
@@ -21,28 +62,12 @@ export class Module {
21
62
  get prop() {
22
63
  return this._mutableProp.prop;
23
64
  }
24
- /**
25
- * Responsive properties
26
- */
27
- _mutableProp;
28
- /**
29
- * Module Callbacks
30
- */
31
- _callbacks;
32
65
  /**
33
66
  * Module Callbacks
34
67
  */
35
68
  get callbacks() {
36
69
  return this._callbacks;
37
70
  }
38
- /**
39
- * Module listeners
40
- */
41
- _listeners;
42
- /**
43
- * Vevet Application
44
- */
45
- _app;
46
71
  /**
47
72
  * Module prefix
48
73
  */
@@ -55,53 +80,12 @@ export class Module {
55
80
  get name() {
56
81
  return this.constructor.name;
57
82
  }
58
- /**
59
- * If the module is initialized
60
- */
61
- _inited = false;
62
83
  get inited() {
63
84
  return this._inited;
64
85
  }
65
- /**
66
- * If the module is destroyed
67
- */
68
- _destroyed;
69
86
  get destroyed() {
70
87
  return this._destroyed;
71
88
  }
72
- /**
73
- * @example
74
- * const mod = new Module();
75
- */
76
- constructor(
77
- /**
78
- * Properties on script start
79
- */
80
- initialProp,
81
- /**
82
- * Defines if you need to call {@linkcode Module.init} at the constructor's end.
83
- * If you want to add responsive properties, set this argument to FALSE.
84
- */
85
- init = true) {
86
- // set vars
87
- if (window.vevetApp) {
88
- this._app = window.vevetApp;
89
- }
90
- else {
91
- throwVevetAppError();
92
- }
93
- // set default vars
94
- this._destroyed = false;
95
- this._listeners = [];
96
- // create callbacks
97
- this._callbacks = new Callbacks();
98
- // create mutable properties
99
- const prop = mergeWithoutArrays(this._getDefaultProp(), initialProp || {});
100
- this._mutableProp = new MutableProp(prop, this._onPropResponsive.bind(this), this._onPropChange.bind(this), this.name);
101
- if (init) {
102
- this.init();
103
- }
104
- }
105
89
  /**
106
90
  * Add responsive rules
107
91
  */
@@ -182,10 +166,6 @@ export class Module {
182
166
  _setEvents() {
183
167
  // code
184
168
  }
185
- /**
186
- * Viewport callbacks
187
- */
188
- _viewportCallbacks = [];
189
169
  /**
190
170
  * Add a viewport callback that will be removed on class destroy
191
171
  * {@see Viewport}
@@ -14,38 +14,6 @@ import { mergeWithoutArrays } from '../utils/common';
14
14
  * </ul>
15
15
  */
16
16
  export class MutableProp {
17
- _initProp;
18
- _onResponsive;
19
- _onChange;
20
- _name;
21
- /**
22
- * Vevet Application.
23
- */
24
- _app;
25
- /**
26
- * @description Reference properties.
27
- * These properties may change only through {@linkcode MutableProp.changeProp}.
28
- */
29
- _refProp;
30
- /**
31
- * Current properties.
32
- * These properties may change both on {@linkcode MutableProp.changeProp} and resize.
33
- */
34
- _prop;
35
- /**
36
- * A set of responsive rules
37
- */
38
- _responsiveRules = [];
39
- /**
40
- * Get current properties
41
- */
42
- get prop() {
43
- return this._prop;
44
- }
45
- /**
46
- * Viewport callback
47
- */
48
- _viewportCallback;
49
17
  /**
50
18
  * @example
51
19
  * const static = {
@@ -84,10 +52,20 @@ export class MutableProp {
84
52
  this._onResponsive = _onResponsive;
85
53
  this._onChange = _onChange;
86
54
  this._name = _name;
55
+ /**
56
+ * A set of responsive rules
57
+ */
58
+ this._responsiveRules = [];
87
59
  this._app = window.vevetApp;
88
60
  this._refProp = mergeWithoutArrays({}, _initProp);
89
61
  this._prop = mergeWithoutArrays({}, _initProp);
90
62
  }
63
+ /**
64
+ * Get current properties
65
+ */
66
+ get prop() {
67
+ return this._prop;
68
+ }
91
69
  /**
92
70
  * Add responsive rules
93
71
  */
@@ -6,7 +6,6 @@ export class Plugin extends Module {
6
6
  constructor(initialProp) {
7
7
  super(initialProp, false);
8
8
  }
9
- _component;
10
9
  get component() {
11
10
  return this._component;
12
11
  }
@@ -4,29 +4,6 @@ import { boundVal } from '../../utils/math';
4
4
  * Launch an animation frame with a certain FPS
5
5
  */
6
6
  export class AnimationFrame extends Component {
7
- /**
8
- * If the frame is launched
9
- */
10
- _isPlaying;
11
- get isPlaying() {
12
- return this._isPlaying;
13
- }
14
- /**
15
- * The animation frame
16
- */
17
- _frame;
18
- /**
19
- * Previous frame segment
20
- */
21
- _frameIndex;
22
- /**
23
- * Timestamp
24
- */
25
- _timeStamp;
26
- /**
27
- * Previous frame duration
28
- */
29
- _prevFrameTime;
30
7
  constructor(initialProp, init = true) {
31
8
  super(initialProp, false);
32
9
  this._isPlaying = false;
@@ -38,15 +15,14 @@ export class AnimationFrame extends Component {
38
15
  this.init();
39
16
  }
40
17
  }
18
+ get isPlaying() {
19
+ return this._isPlaying;
20
+ }
41
21
  /**
42
22
  * Get default properties
43
23
  */
44
24
  _getDefaultProp() {
45
- return {
46
- ...super._getDefaultProp(),
47
- fps: 140,
48
- run: false,
49
- };
25
+ return Object.assign(Object.assign({}, super._getDefaultProp()), { fps: 140, run: false });
50
26
  }
51
27
  // Extra constructor
52
28
  _constructor() {
@@ -6,30 +6,38 @@ import { Component } from '../../base/Component';
6
6
  * implement automatic resize.
7
7
  */
8
8
  export class Ctx2D extends Component {
9
+ constructor(initialProp, init = true) {
10
+ super(initialProp, false);
11
+ // set default values
12
+ this._width = 0;
13
+ this._height = 0;
14
+ this._dpr = 1;
15
+ // create canvas
16
+ const { append, container } = this.prop;
17
+ const parent = (append && container) ? container : undefined;
18
+ this._canvas = createElement('canvas', {
19
+ parent,
20
+ });
21
+ this._ctx = this._canvas.getContext('2d');
22
+ // and resize it for the first time
23
+ this.resize();
24
+ // initialize the class
25
+ if (init) {
26
+ this.init();
27
+ }
28
+ }
9
29
  /**
10
30
  * The parent container of the canvas
11
31
  */
12
32
  get container() {
13
33
  return this.prop.container;
14
34
  }
15
- /**
16
- * The Canvas element itself
17
- */
18
- _canvas;
19
35
  get canvas() {
20
36
  return this._canvas;
21
37
  }
22
- /**
23
- * 2D Context
24
- */
25
- _ctx;
26
38
  get ctx() {
27
39
  return this._ctx;
28
40
  }
29
- /**
30
- * The width of the canvas
31
- */
32
- _width;
33
41
  get width() {
34
42
  return this._width;
35
43
  }
@@ -39,10 +47,6 @@ export class Ctx2D extends Component {
39
47
  get nonDPRWidth() {
40
48
  return this.width / this.dpr;
41
49
  }
42
- /**
43
- * The height of the canvas
44
- */
45
- _height;
46
50
  get height() {
47
51
  return this._height;
48
52
  }
@@ -52,43 +56,11 @@ export class Ctx2D extends Component {
52
56
  get nonDPRHeight() {
53
57
  return this.height / this.dpr;
54
58
  }
55
- /**
56
- * Device pixel ratio
57
- */
58
- _dpr;
59
59
  get dpr() {
60
60
  return this._dpr;
61
61
  }
62
- constructor(initialProp, init = true) {
63
- super(initialProp, false);
64
- // set default values
65
- this._width = 0;
66
- this._height = 0;
67
- this._dpr = 1;
68
- // create canvas
69
- const { append, container } = this.prop;
70
- const parent = (append && container) ? container : undefined;
71
- this._canvas = createElement('canvas', {
72
- parent,
73
- });
74
- this._ctx = this._canvas.getContext('2d');
75
- // and resize it for the first time
76
- this.resize();
77
- // initialize the class
78
- if (init) {
79
- this.init();
80
- }
81
- }
82
62
  _getDefaultProp() {
83
- return {
84
- ...super._getDefaultProp(),
85
- container: false,
86
- append: true,
87
- updateOnResize: false,
88
- width: false,
89
- height: false,
90
- dpr: false,
91
- };
63
+ return Object.assign(Object.assign({}, super._getDefaultProp()), { container: false, append: true, updateOnResize: false, width: false, height: false, dpr: false });
92
64
  }
93
65
  // Set Module Events
94
66
  _setEvents() {
@@ -5,11 +5,7 @@ import { Ctx2D } from './Ctx2D';
5
5
  */
6
6
  export class Ctx2DPrerender extends Ctx2D {
7
7
  _getDefaultProp() {
8
- return {
9
- ...super._getDefaultProp(),
10
- media: false,
11
- posRule: 'cover',
12
- };
8
+ return Object.assign(Object.assign({}, super._getDefaultProp()), { media: false, posRule: 'cover' });
13
9
  }
14
10
  /**
15
11
  * Resize the canvas
@@ -19,14 +15,32 @@ export class Ctx2DPrerender extends Ctx2D {
19
15
  this._prerender();
20
16
  }
21
17
  _prerender() {
18
+ // check if can render
19
+ if (this.width === 0 || this.height === 0) {
20
+ return;
21
+ }
22
22
  // check if media exists
23
23
  const { media } = this.prop;
24
24
  if (!media) {
25
25
  return;
26
26
  }
27
+ // get source info
28
+ let source;
29
+ let sourceWidth;
30
+ let sourceHeight;
31
+ if (media instanceof Ctx2D) {
32
+ source = media.canvas;
33
+ sourceWidth = media.width;
34
+ sourceHeight = media.height;
35
+ }
36
+ else {
37
+ source = media;
38
+ }
27
39
  // get media sizes
28
40
  const size = getPos({
29
- source: media,
41
+ source,
42
+ sourceWidth,
43
+ sourceHeight,
30
44
  rule: this.prop.posRule,
31
45
  scale: 1,
32
46
  width: this.width,
@@ -34,7 +48,7 @@ export class Ctx2DPrerender extends Ctx2D {
34
48
  });
35
49
  this._ctx.clearRect(0, 0, this.width, this.height);
36
50
  // render the media
37
- this._ctx.drawImage(media, 0, 0, size.sourceWidth, size.sourceHeight, size.x, size.y, size.width, size.height);
51
+ this._ctx.drawImage(source, size.x, size.y, size.width, size.height);
38
52
  // launch callbacks on prerender
39
53
  this.callbacks.tbt('prerender', false);
40
54
  }
@@ -6,19 +6,35 @@ import lerp from '../../utils/math/lerp';
6
6
  * Creates a smooth custom cursor
7
7
  */
8
8
  export class CustomCursor extends Component {
9
+ constructor(initialProp, init = true) {
10
+ super(initialProp, false);
11
+ // get cursor container
12
+ const container = selectOne(this.prop.container);
13
+ if (container) {
14
+ this._container = container;
15
+ }
16
+ else {
17
+ throw new Error(`No cursor container for ${this.prop.container}`);
18
+ }
19
+ this._containerIsWindow = container instanceof Window;
20
+ // set default vars
21
+ this._x = 0;
22
+ this._xTarget = 0;
23
+ this._y = 0;
24
+ this._yTarget = 0;
25
+ this._currentFPS = 60;
26
+ this._canPlay = this.prop.run;
27
+ // initialize the class
28
+ if (init) {
29
+ this.init();
30
+ }
31
+ }
9
32
  _getDefaultProp() {
10
- return {
11
- ...super._getDefaultProp(),
12
- container: window,
13
- run: true,
14
- hideNativeCursor: false,
15
- render: {
33
+ return Object.assign(Object.assign({}, super._getDefaultProp()), { container: window, run: true, hideNativeCursor: false, render: {
16
34
  lerp: 0.2,
17
35
  lerpToFixed: 2,
18
36
  normalizeLerp: false,
19
- },
20
- autoStop: true,
21
- };
37
+ }, autoStop: true });
22
38
  }
23
39
  get prefix() {
24
40
  return `${this._app.prefix}custom-cursor`;
@@ -29,8 +45,6 @@ export class CustomCursor extends Component {
29
45
  get container() {
30
46
  return this._container;
31
47
  }
32
- _container;
33
- _containerIsWindow;
34
48
  /**
35
49
  * The element for events
36
50
  */
@@ -52,71 +66,24 @@ export class CustomCursor extends Component {
52
66
  get outerCursor() {
53
67
  return this._outerCursor;
54
68
  }
55
- _outerCursor;
56
69
  /**
57
70
  * Cursor element (inner element)
58
71
  */
59
72
  get innerCursor() {
60
73
  return this._innerCursor;
61
74
  }
62
- _innerCursor;
63
- /**
64
- * Animation frame
65
- */
66
- _animationFrame;
67
- /**
68
- * Current FPS. Used to normalize LERP ease
69
- */
70
- _currentFPS;
71
- /**
72
- * If can play animation
73
- */
74
- _canPlay;
75
75
  /**
76
76
  * Current X coordinate relative to Window
77
77
  */
78
78
  get x() {
79
79
  return this._x;
80
80
  }
81
- _x;
82
- /**
83
- * Target coordinate
84
- */
85
- _xTarget;
86
81
  /**
87
82
  * Current Y coordinate relative to Window
88
83
  */
89
84
  get y() {
90
85
  return this._y;
91
86
  }
92
- _y;
93
- /**
94
- * Target coordinate
95
- */
96
- _yTarget;
97
- constructor(initialProp, init = true) {
98
- super(initialProp, false);
99
- // get cursor container
100
- const container = selectOne(this.prop.container);
101
- if (container) {
102
- this._container = container;
103
- }
104
- else {
105
- throw new Error(`No cursor container for ${this.prop.container}`);
106
- }
107
- this._containerIsWindow = container instanceof Window;
108
- // set default vars
109
- this._x = 0;
110
- this._xTarget = 0;
111
- this._y = 0;
112
- this._yTarget = 0;
113
- this._currentFPS = 60;
114
- this._canPlay = this.prop.run;
115
- // initialize the class
116
- if (init) {
117
- this.init();
118
- }
119
- }
120
87
  // Extra constructor
121
88
  _constructor() {
122
89
  super._constructor();
@@ -4,13 +4,27 @@ import { Component } from '../../base/Component';
4
4
  * Drag & Swipe events. An abstract class
5
5
  */
6
6
  export class Dragger extends Component {
7
+ constructor(initialProp, init = true) {
8
+ super(initialProp, false);
9
+ // get container
10
+ this._container = selectOne(this.prop.container);
11
+ if (!isElement(this._container) && !isWindow(this._container)) {
12
+ throw new Error('No container');
13
+ }
14
+ // set default vars
15
+ this._runtimeEvents = [];
16
+ this._isDragging = false;
17
+ this._pointerID = null;
18
+ this._coords = { x: 0, y: 0 };
19
+ this._prevCoords = { x: 0, y: 0 };
20
+ this._startCoords = { x: 0, y: 0 };
21
+ // initialize the class
22
+ if (init) {
23
+ this.init();
24
+ }
25
+ }
7
26
  _getDefaultProp() {
8
- return {
9
- ...super._getDefaultProp(),
10
- container: `#${this.prefix}`,
11
- usePassive: false,
12
- enabled: true,
13
- };
27
+ return Object.assign(Object.assign({}, super._getDefaultProp()), { container: `#${this.prefix}`, usePassive: false, enabled: true });
14
28
  }
15
29
  get prefix() {
16
30
  return `${this._app.prefix}dragger`;
@@ -21,59 +35,24 @@ export class Dragger extends Component {
21
35
  get container() {
22
36
  return this._container;
23
37
  }
24
- _container;
25
- /**
26
- * Runtime events
27
- */
28
- _runtimeEvents;
29
38
  /**
30
39
  * If is dragging at the moment
31
40
  */
32
41
  get isDragging() {
33
42
  return this._isDragging;
34
43
  }
35
- _isDragging;
36
- /**
37
- * Current pointer id
38
- */
39
- _pointerID;
40
44
  /**
41
45
  * Current coordinates relative to the Window
42
46
  */
43
47
  get coords() {
44
48
  return this._coords;
45
49
  }
46
- _coords;
47
- /**
48
- * Last coordinates relative to the window
49
- */
50
- _prevCoords;
51
50
  /**
52
51
  * Coordinates on drag start
53
52
  */
54
53
  get startCoords() {
55
54
  return this._startCoords;
56
55
  }
57
- _startCoords;
58
- constructor(initialProp, init = true) {
59
- super(initialProp, false);
60
- // get container
61
- this._container = selectOne(this.prop.container);
62
- if (!isElement(this._container) && !isWindow(this._container)) {
63
- throw new Error('No container');
64
- }
65
- // set default vars
66
- this._runtimeEvents = [];
67
- this._isDragging = false;
68
- this._pointerID = null;
69
- this._coords = { x: 0, y: 0 };
70
- this._prevCoords = { x: 0, y: 0 };
71
- this._startCoords = { x: 0, y: 0 };
72
- // initialize the class
73
- if (init) {
74
- this.init();
75
- }
76
- }
77
56
  /**
78
57
  * Set component events
79
58
  */
@@ -4,10 +4,7 @@ import { Dragger } from './Dragger';
4
4
  */
5
5
  export class DraggerDirection extends Dragger {
6
6
  _getDefaultProp() {
7
- return {
8
- ...super._getDefaultProp(),
9
- min: 75,
10
- };
7
+ return Object.assign(Object.assign({}, super._getDefaultProp()), { min: 75 });
11
8
  }
12
9
  /**
13
10
  * Event on drag end