@egjs/flicking 3.9.2 → 3.9.3
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.
- package/dist/flicking.esm.js +8 -2
- package/dist/flicking.esm.js.map +1 -1
- package/dist/flicking.js +8 -2
- package/dist/flicking.js.map +1 -1
- package/dist/flicking.min.js +2 -2
- package/dist/flicking.min.js.map +1 -1
- package/dist/flicking.pkgd.js +8 -2
- package/dist/flicking.pkgd.js.map +1 -1
- package/dist/flicking.pkgd.min.js +2 -2
- package/dist/flicking.pkgd.min.js.map +1 -1
- package/doc/eg.Flicking.html +12780 -0
- package/doc/fonts/glyphicons-halflings-regular.eot +0 -0
- package/doc/fonts/glyphicons-halflings-regular.svg +229 -0
- package/doc/fonts/glyphicons-halflings-regular.ttf +0 -0
- package/doc/fonts/glyphicons-halflings-regular.woff +0 -0
- package/doc/global.html +417 -0
- package/doc/img/i.png +0 -0
- package/doc/img/type_white.svg +26 -0
- package/doc/index.html +503 -0
- package/doc/node_modules_@egjs_component_src_Component.ts.html +627 -0
- package/doc/scripts/bootstrap.min.js +7 -0
- package/doc/scripts/jquery.min.js +6 -0
- package/doc/scripts/jquery.min.map +1 -0
- package/doc/scripts/linenumber.js +29 -0
- package/doc/scripts/main.js +101 -0
- package/doc/scripts/prettify/Apache-License-2.0.txt +202 -0
- package/doc/scripts/prettify/lang-css.js +2 -0
- package/doc/scripts/prettify/prettify.js +28 -0
- package/doc/scripts/underscore-min.js +6 -0
- package/doc/scripts/underscore-min.map +1 -0
- package/doc/src_Flicking.ts.html +1268 -0
- package/doc/src_types.ts.html +831 -0
- package/doc/styles/bootstrap.min.css +7 -0
- package/doc/styles/jaguar.css +469 -0
- package/doc/styles/prettify-jsdoc.css +111 -0
- package/doc/styles/prettify-tomorrow.css +136 -0
- package/doc/styles/style.css +13 -0
- package/docs/build/release/3.9.2/dist/flicking.esm.js +5137 -0
- package/docs/build/release/3.9.2/dist/flicking.esm.js.map +1 -0
- package/docs/build/release/3.9.2/dist/flicking.js +5144 -0
- package/docs/build/release/3.9.2/dist/flicking.js.map +1 -0
- package/docs/build/release/3.9.2/dist/flicking.min.js +10 -0
- package/docs/build/release/3.9.2/dist/flicking.min.js.map +1 -0
- package/docs/build/release/3.9.2/dist/flicking.pkgd.js +11473 -0
- package/docs/build/release/3.9.2/dist/flicking.pkgd.js.map +1 -0
- package/docs/build/release/3.9.2/dist/flicking.pkgd.min.js +10 -0
- package/docs/build/release/3.9.2/dist/flicking.pkgd.min.js.map +1 -0
- package/docs/build/release/3.9.3/dist/flicking.esm.js +5143 -0
- package/docs/build/release/3.9.3/dist/flicking.esm.js.map +1 -0
- package/docs/build/release/3.9.3/dist/flicking.js +5150 -0
- package/docs/build/release/3.9.3/dist/flicking.js.map +1 -0
- package/docs/build/release/3.9.3/dist/flicking.min.js +10 -0
- package/docs/build/release/3.9.3/dist/flicking.min.js.map +1 -0
- package/docs/build/release/3.9.3/dist/flicking.pkgd.js +11479 -0
- package/docs/build/release/3.9.3/dist/flicking.pkgd.js.map +1 -0
- package/docs/build/release/3.9.3/dist/flicking.pkgd.min.js +10 -0
- package/docs/build/release/3.9.3/dist/flicking.pkgd.min.js.map +1 -0
- package/package.json +1 -1
- package/src/components/PanelManager.ts +5 -0
|
@@ -0,0 +1,627 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html>
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="utf-8">
|
|
5
|
+
<title>Source: node_modules/@egjs/component/src/Component.ts | egjs::Flicking - API</title>
|
|
6
|
+
|
|
7
|
+
<meta name="description" content="A module used to implement flicking interactions. With this module, you can make flicking gestures, which are ways to navigate left and right to move between panels arranged side by side." />
|
|
8
|
+
|
|
9
|
+
<meta name="keywords" content="UI Component, egjs, flicking, carousel" />
|
|
10
|
+
<meta name="keyword" content="UI Component, egjs, flicking, carousel" />
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
<meta property="og:title" content=""/>
|
|
15
|
+
<meta property="og:type" content="website"/>
|
|
16
|
+
<meta property="og:image" content=""/>
|
|
17
|
+
|
|
18
|
+
<meta property="og:url" content=""/>
|
|
19
|
+
|
|
20
|
+
<script src="scripts/prettify/prettify.js"></script>
|
|
21
|
+
<script src="scripts/prettify/lang-css.js"></script>
|
|
22
|
+
<script src="scripts/jquery.min.js"></script>
|
|
23
|
+
<!--[if lt IE 9]>
|
|
24
|
+
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
|
|
25
|
+
<![endif]-->
|
|
26
|
+
|
|
27
|
+
<link rel="canonical" href="https://naver.github.io/egjs-flicking/release/latest/doc/"/>
|
|
28
|
+
|
|
29
|
+
<link type="text/css" rel="stylesheet" href="styles/prettify-tomorrow.css">
|
|
30
|
+
<link type="text/css" rel="stylesheet" href="styles/bootstrap.min.css">
|
|
31
|
+
<link type="text/css" rel="stylesheet" href="styles/jaguar.css">
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
<script>
|
|
35
|
+
var config = {"monospaceLinks":true,"cleverLinks":true,"default":{"outputSourceFiles":true},"applicationName":"eg.Flicking","disqus":"egjs","googleAnalytics":"UA-70842526-17","openGraph":{"title":"","type":"website","image":"","site_name":"","url":""},"meta":{"title":"egjs::Flicking - API","description":"A module used to implement flicking interactions. With this module, you can make flicking gestures, which are ways to navigate left and right to move between panels arranged side by side.","keyword":"UI Component, egjs, flicking, carousel"},"linenums":true,"link":{"canonical":"https://naver.github.io/egjs-flicking/release/latest/doc/"}};
|
|
36
|
+
</script>
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
<script type="text/javascript">
|
|
41
|
+
var _gaq = _gaq || [];
|
|
42
|
+
_gaq.push(['_setAccount', config.googleAnalytics]);
|
|
43
|
+
_gaq.push(['_trackPageview']);
|
|
44
|
+
|
|
45
|
+
(function() {
|
|
46
|
+
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
|
|
47
|
+
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
|
|
48
|
+
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
|
|
49
|
+
})();
|
|
50
|
+
</script>
|
|
51
|
+
|
|
52
|
+
</head>
|
|
53
|
+
<body>
|
|
54
|
+
<div id="wrap" class="clearfix">
|
|
55
|
+
|
|
56
|
+
<div class="navigation">
|
|
57
|
+
<h3 class="applicationName">
|
|
58
|
+
<a href="//naver.github.io/egjs/"><img style="width:40px; height:20px;" src="img/type_white.svg"/></a>
|
|
59
|
+
|
|
60
|
+
<!-- Homepage link (prefer link.home than applicationName) -->
|
|
61
|
+
|
|
62
|
+
<a href="//naver.github.io/egjs-flicking/">Flicking</a>
|
|
63
|
+
|
|
64
|
+
</h3>
|
|
65
|
+
|
|
66
|
+
<div class="search">
|
|
67
|
+
<input id="search" type="text" class="form-control input-sm" placeholder="Search Documentations">
|
|
68
|
+
</div>
|
|
69
|
+
<ul class="list">
|
|
70
|
+
<li class="item">
|
|
71
|
+
<span class="title">
|
|
72
|
+
<a href="index.html">README</a>
|
|
73
|
+
</span>
|
|
74
|
+
</li>
|
|
75
|
+
|
|
76
|
+
<!-- Non Grouping Version -->
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
<li class="item" data-name="eg.Flicking">
|
|
81
|
+
<span class="title">
|
|
82
|
+
<a href="eg.Flicking.html">eg.Flicking</a>
|
|
83
|
+
|
|
84
|
+
</span>
|
|
85
|
+
<ul class="members itemMembers expends">
|
|
86
|
+
|
|
87
|
+
<span class="subtitle">Members</span>
|
|
88
|
+
|
|
89
|
+
<li data-name="eg.Flicking.DIRECTION"><a href="eg.Flicking.html#.DIRECTION">DIRECTION</a></li>
|
|
90
|
+
|
|
91
|
+
<li data-name="eg.Flicking.EVENTS"><a href="eg.Flicking.html#.EVENTS">EVENTS</a></li>
|
|
92
|
+
|
|
93
|
+
<li data-name="eg.Flicking.VERSION"><a href="eg.Flicking.html#.VERSION">VERSION</a></li>
|
|
94
|
+
|
|
95
|
+
</ul>
|
|
96
|
+
<ul class="typedefs itemMembers expends">
|
|
97
|
+
|
|
98
|
+
<span class="subtitle">Typedefs</span>
|
|
99
|
+
|
|
100
|
+
<li data-name="eg.Flicking.ChangeEvent"><a href="eg.Flicking.html#.ChangeEvent">ChangeEvent</a></li>
|
|
101
|
+
|
|
102
|
+
<li data-name="eg.Flicking.ContentErrorEvent"><a href="eg.Flicking.html#.ContentErrorEvent">ContentErrorEvent</a></li>
|
|
103
|
+
|
|
104
|
+
<li data-name="eg.Flicking.ContentLoadEvent"><a href="eg.Flicking.html#.ContentLoadEvent">ContentLoadEvent</a></li>
|
|
105
|
+
|
|
106
|
+
<li data-name="eg.Flicking.ElementLike"><a href="eg.Flicking.html#.ElementLike">ElementLike</a></li>
|
|
107
|
+
|
|
108
|
+
<li data-name="eg.Flicking.FlickingEvent"><a href="eg.Flicking.html#.FlickingEvent">FlickingEvent</a></li>
|
|
109
|
+
|
|
110
|
+
<li data-name="eg.Flicking.FlickingOptions"><a href="eg.Flicking.html#.FlickingOptions">FlickingOptions</a></li>
|
|
111
|
+
|
|
112
|
+
<li data-name="eg.Flicking.FlickingPanel"><a href="eg.Flicking.html#.FlickingPanel">FlickingPanel</a></li>
|
|
113
|
+
|
|
114
|
+
<li data-name="eg.Flicking.FlickingStatus"><a href="eg.Flicking.html#.FlickingStatus">FlickingStatus</a></li>
|
|
115
|
+
|
|
116
|
+
<li data-name="eg.Flicking.MoveTypeFreeScrollOption"><a href="eg.Flicking.html#.MoveTypeFreeScrollOption">MoveTypeFreeScrollOption</a></li>
|
|
117
|
+
|
|
118
|
+
<li data-name="eg.Flicking.MoveTypeOption"><a href="eg.Flicking.html#.MoveTypeOption">MoveTypeOption</a></li>
|
|
119
|
+
|
|
120
|
+
<li data-name="eg.Flicking.MoveTypeSnapOption"><a href="eg.Flicking.html#.MoveTypeSnapOption">MoveTypeSnapOption</a></li>
|
|
121
|
+
|
|
122
|
+
<li data-name="eg.Flicking.NeedPanelEvent"><a href="eg.Flicking.html#.NeedPanelEvent">NeedPanelEvent</a></li>
|
|
123
|
+
|
|
124
|
+
<li data-name="eg.Flicking.Plugin"><a href="eg.Flicking.html#.Plugin">Plugin</a></li>
|
|
125
|
+
|
|
126
|
+
<li data-name="eg.Flicking.SelectEvent"><a href="eg.Flicking.html#.SelectEvent">SelectEvent</a></li>
|
|
127
|
+
|
|
128
|
+
<li data-name="eg.Flicking.VisibleChangeEvent"><a href="eg.Flicking.html#.VisibleChangeEvent">VisibleChangeEvent</a></li>
|
|
129
|
+
|
|
130
|
+
</ul>
|
|
131
|
+
<ul class="methods itemMembers expends">
|
|
132
|
+
|
|
133
|
+
<span class="subtitle">Methods</span>
|
|
134
|
+
|
|
135
|
+
<li data-name="eg.Flicking#addPlugins"><a href="eg.Flicking.html#addPlugins">addPlugins</a></li>
|
|
136
|
+
|
|
137
|
+
<li data-name="eg.Flicking#append"><a href="eg.Flicking.html#append">append</a></li>
|
|
138
|
+
|
|
139
|
+
<li data-name="eg.Flicking#destroy"><a href="eg.Flicking.html#destroy">destroy</a></li>
|
|
140
|
+
|
|
141
|
+
<li data-name="eg.Flicking#disableInput"><a href="eg.Flicking.html#disableInput">disableInput</a></li>
|
|
142
|
+
|
|
143
|
+
<li data-name="eg.Flicking#enableInput"><a href="eg.Flicking.html#enableInput">enableInput</a></li>
|
|
144
|
+
|
|
145
|
+
<li data-name="eg.Flicking#getAllPanels"><a href="eg.Flicking.html#getAllPanels">getAllPanels</a></li>
|
|
146
|
+
|
|
147
|
+
<li data-name="eg.Flicking#getCloneCount"><a href="eg.Flicking.html#getCloneCount">getCloneCount</a></li>
|
|
148
|
+
|
|
149
|
+
<li data-name="eg.Flicking#getCurrentPanel"><a href="eg.Flicking.html#getCurrentPanel">getCurrentPanel</a></li>
|
|
150
|
+
|
|
151
|
+
<li data-name="eg.Flicking#getElement"><a href="eg.Flicking.html#getElement">getElement</a></li>
|
|
152
|
+
|
|
153
|
+
<li data-name="eg.Flicking#getIndex"><a href="eg.Flicking.html#getIndex">getIndex</a></li>
|
|
154
|
+
|
|
155
|
+
<li data-name="eg.Flicking#getLastIndex"><a href="eg.Flicking.html#getLastIndex">getLastIndex</a></li>
|
|
156
|
+
|
|
157
|
+
<li data-name="eg.Flicking#getPanel"><a href="eg.Flicking.html#getPanel">getPanel</a></li>
|
|
158
|
+
|
|
159
|
+
<li data-name="eg.Flicking#getPanelCount"><a href="eg.Flicking.html#getPanelCount">getPanelCount</a></li>
|
|
160
|
+
|
|
161
|
+
<li data-name="eg.Flicking#getSize"><a href="eg.Flicking.html#getSize">getSize</a></li>
|
|
162
|
+
|
|
163
|
+
<li data-name="eg.Flicking#getStatus"><a href="eg.Flicking.html#getStatus">getStatus</a></li>
|
|
164
|
+
|
|
165
|
+
<li data-name="eg.Flicking#getVisiblePanels"><a href="eg.Flicking.html#getVisiblePanels">getVisiblePanels</a></li>
|
|
166
|
+
|
|
167
|
+
<li data-name="eg.Flicking#hasOn"><a href="eg.Flicking.html#hasOn">hasOn</a> <img src="img/i.png" width="14" title="inherited" alt="inherited"></li>
|
|
168
|
+
|
|
169
|
+
<li data-name="eg.Flicking#isPlaying"><a href="eg.Flicking.html#isPlaying">isPlaying</a></li>
|
|
170
|
+
|
|
171
|
+
<li data-name="eg.Flicking#moveTo"><a href="eg.Flicking.html#moveTo">moveTo</a></li>
|
|
172
|
+
|
|
173
|
+
<li data-name="eg.Flicking#next"><a href="eg.Flicking.html#next">next</a></li>
|
|
174
|
+
|
|
175
|
+
<li data-name="eg.Flicking#off"><a href="eg.Flicking.html#off">off</a> <img src="img/i.png" width="14" title="inherited" alt="inherited"></li>
|
|
176
|
+
|
|
177
|
+
<li data-name="eg.Flicking#on"><a href="eg.Flicking.html#on">on</a> <img src="img/i.png" width="14" title="inherited" alt="inherited"></li>
|
|
178
|
+
|
|
179
|
+
<li data-name="eg.Flicking#once"><a href="eg.Flicking.html#once">once</a> <img src="img/i.png" width="14" title="inherited" alt="inherited"></li>
|
|
180
|
+
|
|
181
|
+
<li data-name="eg.Flicking#prepend"><a href="eg.Flicking.html#prepend">prepend</a></li>
|
|
182
|
+
|
|
183
|
+
<li data-name="eg.Flicking#prev"><a href="eg.Flicking.html#prev">prev</a></li>
|
|
184
|
+
|
|
185
|
+
<li data-name="eg.Flicking#remove"><a href="eg.Flicking.html#remove">remove</a></li>
|
|
186
|
+
|
|
187
|
+
<li data-name="eg.Flicking#removePlugins"><a href="eg.Flicking.html#removePlugins">removePlugins</a></li>
|
|
188
|
+
|
|
189
|
+
<li data-name="eg.Flicking#replace"><a href="eg.Flicking.html#replace">replace</a></li>
|
|
190
|
+
|
|
191
|
+
<li data-name="eg.Flicking#resize"><a href="eg.Flicking.html#resize">resize</a></li>
|
|
192
|
+
|
|
193
|
+
<li data-name="eg.Flicking#setLastIndex"><a href="eg.Flicking.html#setLastIndex">setLastIndex</a></li>
|
|
194
|
+
|
|
195
|
+
<li data-name="eg.Flicking#setStatus"><a href="eg.Flicking.html#setStatus">setStatus</a></li>
|
|
196
|
+
|
|
197
|
+
<li data-name="eg.Flicking#trigger"><a href="eg.Flicking.html#trigger">trigger</a> <img src="img/i.png" width="14" title="inherited" alt="inherited"></li>
|
|
198
|
+
|
|
199
|
+
</ul>
|
|
200
|
+
<ul class="events itemMembers expends">
|
|
201
|
+
|
|
202
|
+
<span class="subtitle">Events</span>
|
|
203
|
+
|
|
204
|
+
<li data-name="eg.Flicking#event:change"><a href="eg.Flicking.html#event:change">change</a></li>
|
|
205
|
+
|
|
206
|
+
<li data-name="eg.Flicking#event:contentError"><a href="eg.Flicking.html#event:contentError">contentError</a></li>
|
|
207
|
+
|
|
208
|
+
<li data-name="eg.Flicking#event:holdEnd"><a href="eg.Flicking.html#event:holdEnd">holdEnd</a></li>
|
|
209
|
+
|
|
210
|
+
<li data-name="eg.Flicking#event:holdStart"><a href="eg.Flicking.html#event:holdStart">holdStart</a></li>
|
|
211
|
+
|
|
212
|
+
<li data-name="eg.Flicking#event:move"><a href="eg.Flicking.html#event:move">move</a></li>
|
|
213
|
+
|
|
214
|
+
<li data-name="eg.Flicking#event:moveEnd"><a href="eg.Flicking.html#event:moveEnd">moveEnd</a></li>
|
|
215
|
+
|
|
216
|
+
<li data-name="eg.Flicking#event:moveStart"><a href="eg.Flicking.html#event:moveStart">moveStart</a></li>
|
|
217
|
+
|
|
218
|
+
<li data-name="eg.Flicking#event:needPanel"><a href="eg.Flicking.html#event:needPanel">needPanel</a></li>
|
|
219
|
+
|
|
220
|
+
<li data-name="eg.Flicking#event:restore"><a href="eg.Flicking.html#event:restore">restore</a></li>
|
|
221
|
+
|
|
222
|
+
<li data-name="eg.Flicking#event:select"><a href="eg.Flicking.html#event:select">select</a></li>
|
|
223
|
+
|
|
224
|
+
<li data-name="eg.Flicking#event:visibleChange"><a href="eg.Flicking.html#event:visibleChange">visibleChange</a></li>
|
|
225
|
+
|
|
226
|
+
</ul>
|
|
227
|
+
|
|
228
|
+
|
|
229
|
+
</li>
|
|
230
|
+
|
|
231
|
+
|
|
232
|
+
|
|
233
|
+
|
|
234
|
+
|
|
235
|
+
|
|
236
|
+
</ul>
|
|
237
|
+
</div>
|
|
238
|
+
|
|
239
|
+
<div class="main">
|
|
240
|
+
<h1 class="page-title" data-filename="node_modules_@egjs_component_src_Component.ts.html">Source: node_modules/@egjs/component/src/Component.ts</h1>
|
|
241
|
+
|
|
242
|
+
|
|
243
|
+
|
|
244
|
+
|
|
245
|
+
<section>
|
|
246
|
+
<article>
|
|
247
|
+
<pre class="prettyprint source linenums"><code>/*
|
|
248
|
+
* Copyright (c) 2015 NAVER Corp.
|
|
249
|
+
* egjs projects are licensed under the MIT license
|
|
250
|
+
*/
|
|
251
|
+
|
|
252
|
+
function isUndefined(value: any): boolean {
|
|
253
|
+
return typeof value === "undefined";
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
interface DefaultProps<T> {
|
|
257
|
+
eventType: string;
|
|
258
|
+
stop: () => void;
|
|
259
|
+
currentTarget: T;
|
|
260
|
+
}
|
|
261
|
+
type NotFunction = { [k: string]: unknown } & ({ bind?: never } | { call?: never });
|
|
262
|
+
type NoArguments = undefined | null | void | never;
|
|
263
|
+
type EventWithRestParam = ((evt: NotFunction, ...restParam: any[]) => any);
|
|
264
|
+
|
|
265
|
+
/**
|
|
266
|
+
* Types that can be used when attaching new event definition as generic on a class
|
|
267
|
+
* @ko 클래스 타입 등록시 사용가능한 타입
|
|
268
|
+
* @example
|
|
269
|
+
* ```
|
|
270
|
+
* new SomeClass<{
|
|
271
|
+
* // Using it as object
|
|
272
|
+
* evt0: {
|
|
273
|
+
* param0: number;
|
|
274
|
+
* param1: string
|
|
275
|
+
* };
|
|
276
|
+
* // Using it as function with other arguments
|
|
277
|
+
* evt1: (arg0: {
|
|
278
|
+
* param0: number;
|
|
279
|
+
* param1: string
|
|
280
|
+
* }, arg1: string, arg2: boolean) => boolean;
|
|
281
|
+
* }>
|
|
282
|
+
* ```
|
|
283
|
+
*/
|
|
284
|
+
type EventDefinition = NotFunction | NoArguments | EventWithRestParam;
|
|
285
|
+
|
|
286
|
+
type EventMap = Record<string, EventDefinition>;
|
|
287
|
+
type EventKey<T extends EventMap> = string & keyof T;
|
|
288
|
+
type EventHash<T extends EventMap, S> = Partial<{ [K in EventKey<T>]: EventCallback<T, K, S> }>;
|
|
289
|
+
|
|
290
|
+
|
|
291
|
+
type EventCallbackFirstParam<P, S> = P extends NoArguments ? DefaultProps<S> : P & DefaultProps<S>;
|
|
292
|
+
type EventCallbackFunction<T extends (...params: any[]) => any, S>
|
|
293
|
+
= T extends (firstParam?: infer F, ...restParams: infer R) => any
|
|
294
|
+
? (firstParam: EventCallbackFirstParam<Required<F>, S>, ...restParams: R) => any
|
|
295
|
+
: (firstParam: DefaultProps<S>) => any;
|
|
296
|
+
|
|
297
|
+
|
|
298
|
+
// In the on and once methods, the defaultProps must be included in the first parameter.
|
|
299
|
+
type EventCallback<T extends EventMap, K extends EventKey<T>, S>
|
|
300
|
+
= T[K] extends (...params: any[]) => any
|
|
301
|
+
? EventCallbackFunction<T[K], S>
|
|
302
|
+
: (event: EventCallbackFirstParam<T[K], S>) => any;
|
|
303
|
+
|
|
304
|
+
type EventTriggerFirstParam<T extends {}> = Pick<T, Exclude<keyof T, keyof DefaultProps<any>>> & Partial<DefaultProps<any>>;
|
|
305
|
+
|
|
306
|
+
|
|
307
|
+
type EventDiff<T, U> = T extends U ? never : T;
|
|
308
|
+
type EventTriggerPartialFunction<T extends (...params: any[]) => any>
|
|
309
|
+
= T extends (firstParam: infer F, ...restParam: infer R) => any
|
|
310
|
+
? (firstParam?: EventTriggerFirstParam<EventDiff<F, undefined>>, ...restParams: R) => any
|
|
311
|
+
: never;
|
|
312
|
+
|
|
313
|
+
type EventTriggerRequiredFunction<T extends (...params: any[]) => any>
|
|
314
|
+
= T extends (firstParam: infer F, ...restParam: infer R) => any
|
|
315
|
+
? (firstParam: EventTriggerFirstParam<F>, ...restParams: R) => any
|
|
316
|
+
: never;
|
|
317
|
+
type EventTriggerFunction<T extends (...params: any[]) => any>
|
|
318
|
+
= Parameters<T> extends Required<Parameters<T>> & [any]
|
|
319
|
+
? EventTriggerRequiredFunction<T>
|
|
320
|
+
: EventTriggerPartialFunction<T>
|
|
321
|
+
|
|
322
|
+
type EventTriggerNoFunction<T>
|
|
323
|
+
= T extends NoArguments
|
|
324
|
+
? (firstParam?: { [key: string]: never }) => any
|
|
325
|
+
: EventTriggerFunction<(fisrtParam: EventTriggerFirstParam<T>) => any>;
|
|
326
|
+
|
|
327
|
+
// You don't need to include defaultProps in the trigger method's first parameter.
|
|
328
|
+
type EventTriggerParams<T extends EventMap, K extends EventKey<T>>
|
|
329
|
+
= Parameters<T[K] extends (...params: any[]) => any
|
|
330
|
+
? EventTriggerFunction<T[K]>
|
|
331
|
+
: EventTriggerNoFunction<T[K]>>;
|
|
332
|
+
|
|
333
|
+
interface DefaultEventMap {
|
|
334
|
+
[key: string]: (firstParam?: { [key: string]: any }, ...restParams: any[]) => any;
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
/**
|
|
338
|
+
* A class used to manage events in a component
|
|
339
|
+
* @ko 컴포넌트의 이벤트을 관리할 수 있게 하는 클래스
|
|
340
|
+
* @alias eg.Component
|
|
341
|
+
*/
|
|
342
|
+
class Component<T extends EventMap = DefaultEventMap> {
|
|
343
|
+
/**
|
|
344
|
+
* Version info string
|
|
345
|
+
* @ko 버전정보 문자열
|
|
346
|
+
* @name VERSION
|
|
347
|
+
* @static
|
|
348
|
+
* @example
|
|
349
|
+
* eg.Component.VERSION; // ex) 2.0.0
|
|
350
|
+
* @memberof eg.Component
|
|
351
|
+
*/
|
|
352
|
+
public static VERSION: string = "#__VERSION__#";
|
|
353
|
+
|
|
354
|
+
/**
|
|
355
|
+
* @deprecated
|
|
356
|
+
* @private
|
|
357
|
+
*/
|
|
358
|
+
public options: { [key: string]: any } = {};
|
|
359
|
+
private _eventHandler: { [keys: string]: EventCallback<T, EventKey<T>, Component<T>>[] };
|
|
360
|
+
|
|
361
|
+
/**
|
|
362
|
+
* @support {"ie": "7+", "ch" : "latest", "ff" : "latest", "sf" : "latest", "edge" : "latest", "ios" : "7+", "an" : "2.1+ (except 3.x)"}
|
|
363
|
+
*/
|
|
364
|
+
constructor() {
|
|
365
|
+
this._eventHandler = {};
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
public trigger<K extends EventKey<T>>(eventName: K, ...params: EventTriggerParams<T, K>): boolean;
|
|
369
|
+
/**
|
|
370
|
+
* Triggers a custom event.
|
|
371
|
+
* @ko 커스텀 이벤트를 발생시킨다
|
|
372
|
+
* @param {string} eventName The name of the custom event to be triggered <ko>발생할 커스텀 이벤트의 이름</ko>
|
|
373
|
+
* @param {object} customEvent Event data to be sent when triggering a custom event <ko>커스텀 이벤트가 발생할 때 전달할 데이터</ko>
|
|
374
|
+
* @param {any[]} restParam Additional parameters when triggering a custom event <ko>커스텀 이벤트가 발생할 때 필요시 추가적으로 전달할 데이터</ko>
|
|
375
|
+
* @return Indicates whether the event has occurred. If the stop() method is called by a custom event handler, it will return false and prevent the event from occurring. <a href="https://github.com/naver/egjs-component/wiki/How-to-make-Component-event-design%3F">Ref</a> <ko>이벤트 발생 여부. 커스텀 이벤트 핸들러에서 stop() 메서드를 호출하면 'false'를 반환하고 이벤트 발생을 중단한다. <a href="https://github.com/naver/egjs-component/wiki/How-to-make-Component-event-design%3F">참고</a></ko>
|
|
376
|
+
* @example
|
|
377
|
+
* ```
|
|
378
|
+
* class Some extends eg.Component {
|
|
379
|
+
* some(){
|
|
380
|
+
* if(this.trigger("beforeHi")){ // When event call to stop return false.
|
|
381
|
+
* this.trigger("hi");// fire hi event.
|
|
382
|
+
* }
|
|
383
|
+
* }
|
|
384
|
+
* }
|
|
385
|
+
*
|
|
386
|
+
* const some = new Some();
|
|
387
|
+
* some.on("beforeHi", (e) => {
|
|
388
|
+
* if(condition){
|
|
389
|
+
* e.stop(); // When event call to stop, `hi` event not call.
|
|
390
|
+
* }
|
|
391
|
+
* });
|
|
392
|
+
* some.on("hi", (e) => {
|
|
393
|
+
* // `currentTarget` is component instance.
|
|
394
|
+
* console.log(some === e.currentTarget); // true
|
|
395
|
+
* });
|
|
396
|
+
* // If you want to more know event design. You can see article.
|
|
397
|
+
* // https://github.com/naver/egjs-component/wiki/How-to-make-Component-event-design%3F
|
|
398
|
+
* ```
|
|
399
|
+
*/
|
|
400
|
+
public trigger<K extends EventKey<T>>(eventName: K, ...params: any[]): boolean {
|
|
401
|
+
let handlerList = this._eventHandler[eventName] || [];
|
|
402
|
+
const hasHandlerList = handlerList.length > 0;
|
|
403
|
+
|
|
404
|
+
if (!hasHandlerList) {
|
|
405
|
+
return true;
|
|
406
|
+
}
|
|
407
|
+
const customEvent = params[0] || {};
|
|
408
|
+
const restParams = params.slice(1);
|
|
409
|
+
|
|
410
|
+
// If detach method call in handler in first time then handler list calls.
|
|
411
|
+
handlerList = handlerList.concat();
|
|
412
|
+
|
|
413
|
+
let isCanceled = false;
|
|
414
|
+
|
|
415
|
+
// This should be done like this to pass previous tests
|
|
416
|
+
(customEvent as any).eventType = eventName;
|
|
417
|
+
(customEvent as any).stop = () => { isCanceled = true; };
|
|
418
|
+
(customEvent as any).currentTarget = this;
|
|
419
|
+
|
|
420
|
+
let arg: any[] = [customEvent];
|
|
421
|
+
|
|
422
|
+
if (restParams.length >= 1) {
|
|
423
|
+
arg = arg.concat(restParams);
|
|
424
|
+
}
|
|
425
|
+
|
|
426
|
+
handlerList.forEach(handler => {
|
|
427
|
+
handler.apply(this, arg);
|
|
428
|
+
});
|
|
429
|
+
|
|
430
|
+
return !isCanceled;
|
|
431
|
+
}
|
|
432
|
+
|
|
433
|
+
public once<K extends EventKey<T>>(eventName: K, handlerToAttach: EventCallback<T, K, this>): this;
|
|
434
|
+
public once(eventHash: EventHash<T, this>): this;
|
|
435
|
+
/**
|
|
436
|
+
* Executed event just one time.
|
|
437
|
+
* @ko 이벤트가 한번만 실행된다.
|
|
438
|
+
* @param {string} eventName The name of the event to be attached <ko>등록할 이벤트의 이름</ko>
|
|
439
|
+
* @param {function} handlerToAttach The handler function of the event to be attached <ko>등록할 이벤트의 핸들러 함수</ko>
|
|
440
|
+
* @return An instance of a component itself<ko>컴포넌트 자신의 인스턴스</ko>
|
|
441
|
+
* @example
|
|
442
|
+
* ```
|
|
443
|
+
* class Some extends eg.Component {
|
|
444
|
+
* hi() {
|
|
445
|
+
* alert("hi");
|
|
446
|
+
* }
|
|
447
|
+
* thing() {
|
|
448
|
+
* this.once("hi", this.hi);
|
|
449
|
+
* }
|
|
450
|
+
*
|
|
451
|
+
* var some = new Some();
|
|
452
|
+
* some.thing();
|
|
453
|
+
* some.trigger("hi");
|
|
454
|
+
* // fire alert("hi");
|
|
455
|
+
* some.trigger("hi");
|
|
456
|
+
* // Nothing happens
|
|
457
|
+
* ```
|
|
458
|
+
*/
|
|
459
|
+
public once<K extends EventKey<T>>(eventName: K | EventHash<T, this>, handlerToAttach?: EventCallback<T, K, this>): this {
|
|
460
|
+
if (typeof eventName === "object" && isUndefined(handlerToAttach)) {
|
|
461
|
+
const eventHash = eventName;
|
|
462
|
+
|
|
463
|
+
for (const key in eventHash) {
|
|
464
|
+
this.once((key as K), eventHash[key] as EventCallback<T, K, this>);
|
|
465
|
+
}
|
|
466
|
+
return this;
|
|
467
|
+
} else if (typeof eventName === "string" && typeof handlerToAttach === "function") {
|
|
468
|
+
const listener: any = (...args: any[]) => {
|
|
469
|
+
handlerToAttach.apply(this, args);
|
|
470
|
+
this.off(eventName, listener);
|
|
471
|
+
}
|
|
472
|
+
|
|
473
|
+
this.on(eventName, listener);
|
|
474
|
+
}
|
|
475
|
+
|
|
476
|
+
return this;
|
|
477
|
+
}
|
|
478
|
+
|
|
479
|
+
/**
|
|
480
|
+
* Checks whether an event has been attached to a component.
|
|
481
|
+
* @ko 컴포넌트에 이벤트가 등록됐는지 확인한다.
|
|
482
|
+
* @param {string} eventName The name of the event to be attached <ko>등록 여부를 확인할 이벤트의 이름</ko>
|
|
483
|
+
* @return {boolean} Indicates whether the event is attached. <ko>이벤트 등록 여부</ko>
|
|
484
|
+
* @example
|
|
485
|
+
* ```
|
|
486
|
+
* class Some extends eg.Component {
|
|
487
|
+
* some() {
|
|
488
|
+
* this.hasOn("hi");// check hi event.
|
|
489
|
+
* }
|
|
490
|
+
* }
|
|
491
|
+
* ```
|
|
492
|
+
*/
|
|
493
|
+
public hasOn<K extends EventKey<T>>(eventName: K): boolean {
|
|
494
|
+
return !!this._eventHandler[eventName];
|
|
495
|
+
}
|
|
496
|
+
|
|
497
|
+
public on<K extends EventKey<T>>(eventName: K, handlerToAttach: EventCallback<T, K, this>): this;
|
|
498
|
+
public on(eventHash: EventHash<T, this>): this;
|
|
499
|
+
/**
|
|
500
|
+
* Attaches an event to a component.
|
|
501
|
+
* @ko 컴포넌트에 이벤트를 등록한다.
|
|
502
|
+
* @param {string} eventName The name of the event to be attached <ko>등록할 이벤트의 이름</ko>
|
|
503
|
+
* @param {function} handlerToAttach The handler function of the event to be attached <ko>등록할 이벤트의 핸들러 함수</ko>
|
|
504
|
+
* @return An instance of a component itself<ko>컴포넌트 자신의 인스턴스</ko>
|
|
505
|
+
* @example
|
|
506
|
+
* ```
|
|
507
|
+
* class Some extends eg.Component {
|
|
508
|
+
* hi() {
|
|
509
|
+
* console.log("hi");
|
|
510
|
+
* }
|
|
511
|
+
* some() {
|
|
512
|
+
* this.on("hi",this.hi); //attach event
|
|
513
|
+
* }
|
|
514
|
+
* }
|
|
515
|
+
* ```
|
|
516
|
+
*/
|
|
517
|
+
public on<K extends EventKey<T>>(eventName: K | EventHash<T, this>, handlerToAttach?: EventCallback<T, K, this>): this {
|
|
518
|
+
if (typeof eventName === "object" && isUndefined(handlerToAttach)) {
|
|
519
|
+
const eventHash = eventName;
|
|
520
|
+
|
|
521
|
+
for (const name in eventHash) {
|
|
522
|
+
this.on(name, eventHash[name] as any);
|
|
523
|
+
}
|
|
524
|
+
|
|
525
|
+
return this;
|
|
526
|
+
} else if (typeof eventName === "string" &&
|
|
527
|
+
typeof handlerToAttach === "function") {
|
|
528
|
+
let handlerList = this._eventHandler[eventName];
|
|
529
|
+
|
|
530
|
+
if (isUndefined(handlerList)) {
|
|
531
|
+
this._eventHandler[eventName] = [];
|
|
532
|
+
handlerList = this._eventHandler[eventName];
|
|
533
|
+
}
|
|
534
|
+
|
|
535
|
+
handlerList.push(handlerToAttach as EventCallback<T, EventKey<T>, this>);
|
|
536
|
+
}
|
|
537
|
+
|
|
538
|
+
return this;
|
|
539
|
+
}
|
|
540
|
+
|
|
541
|
+
public off(eventHash?: EventHash<T, this>): this;
|
|
542
|
+
public off<K extends EventKey<T>>(eventName: K, handlerToDetach?: EventCallback<T, K, this>): this;
|
|
543
|
+
/**
|
|
544
|
+
* Detaches an event from the component.
|
|
545
|
+
* @ko 컴포넌트에 등록된 이벤트를 해제한다
|
|
546
|
+
* @param {string} eventName The name of the event to be detached <ko>해제할 이벤트의 이름</ko>
|
|
547
|
+
* @param {function} handlerToDetach The handler function of the event to be detached <ko>해제할 이벤트의 핸들러 함수</ko>
|
|
548
|
+
* @return An instance of a component itself <ko>컴포넌트 자신의 인스턴스</ko>
|
|
549
|
+
* @example
|
|
550
|
+
* ```
|
|
551
|
+
* class Some extends eg.Component {
|
|
552
|
+
* hi() {
|
|
553
|
+
* console.log("hi");
|
|
554
|
+
* }
|
|
555
|
+
* some() {
|
|
556
|
+
* this.off("hi",this.hi); //detach event
|
|
557
|
+
* }
|
|
558
|
+
* }
|
|
559
|
+
* ```
|
|
560
|
+
*/
|
|
561
|
+
public off<K extends EventKey<T>>(eventName?: K | EventHash<T, this>, handlerToDetach?: EventCallback<T, K, this>): this {
|
|
562
|
+
// Detach all event handlers.
|
|
563
|
+
if (isUndefined(eventName)) {
|
|
564
|
+
this._eventHandler = {};
|
|
565
|
+
return this;
|
|
566
|
+
}
|
|
567
|
+
|
|
568
|
+
// Detach all handlers for eventname or detach event handlers by object.
|
|
569
|
+
if (isUndefined(handlerToDetach)) {
|
|
570
|
+
if (typeof eventName === "string") {
|
|
571
|
+
delete this._eventHandler[eventName];
|
|
572
|
+
return this;
|
|
573
|
+
} else {
|
|
574
|
+
const eventHash = eventName;
|
|
575
|
+
|
|
576
|
+
for (const name in eventHash) {
|
|
577
|
+
this.off(name, eventHash[name] as any);
|
|
578
|
+
}
|
|
579
|
+
return this;
|
|
580
|
+
}
|
|
581
|
+
}
|
|
582
|
+
|
|
583
|
+
// Detach single event handler
|
|
584
|
+
const handlerList = this._eventHandler[eventName as K];
|
|
585
|
+
|
|
586
|
+
if (handlerList) {
|
|
587
|
+
let idx = 0;
|
|
588
|
+
for (const handlerFunction of handlerList) {
|
|
589
|
+
if (handlerFunction === handlerToDetach) {
|
|
590
|
+
handlerList.splice(idx, 1);
|
|
591
|
+
break;
|
|
592
|
+
}
|
|
593
|
+
idx++;
|
|
594
|
+
}
|
|
595
|
+
}
|
|
596
|
+
|
|
597
|
+
return this;
|
|
598
|
+
}
|
|
599
|
+
}
|
|
600
|
+
|
|
601
|
+
export default Component;
|
|
602
|
+
</code></pre>
|
|
603
|
+
</article>
|
|
604
|
+
</section>
|
|
605
|
+
|
|
606
|
+
|
|
607
|
+
|
|
608
|
+
|
|
609
|
+
|
|
610
|
+
|
|
611
|
+
|
|
612
|
+
<!-- disqus code -->
|
|
613
|
+
<div id="disqus_thread"></div>
|
|
614
|
+
<noscript>Please enable JavaScript to view the <a href="http://disqus.com/?ref_noscript">comments powered by Disqus.</a></noscript>
|
|
615
|
+
<a href="//disqus.com" class="dsq-brlink">comments powered by <span class="logo-disqus">Disqus</span></a>
|
|
616
|
+
<!-- // disqus code -->
|
|
617
|
+
|
|
618
|
+
|
|
619
|
+
<footer>
|
|
620
|
+
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 0.3.10</a> on Tue Apr 05 2022 15:59:21 GMT+0900 (Korean Standard Time)
|
|
621
|
+
</footer>
|
|
622
|
+
</div>
|
|
623
|
+
</div>
|
|
624
|
+
<script>prettyPrint();</script>
|
|
625
|
+
<script src="scripts/main.js"></script>
|
|
626
|
+
</body>
|
|
627
|
+
</html>
|