hyperapp-is 0.1.50 → 0.2.1
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/README.md +220 -1557
- package/dist/{hyperapp-is/animation → animation}/easing.d.ts +4 -0
- package/dist/{hyperapp-is/animation → animation}/easing.js +4 -4
- package/dist/{hyperapp-is/animation → animation}/properties.d.ts +9 -16
- package/dist/{hyperapp-is/animation → animation}/properties.js +13 -12
- package/dist/{hyperapp-is/animation → animation}/raf.d.ts +11 -12
- package/dist/animation/raf.js +192 -0
- package/dist/core/component.d.ts +23 -0
- package/dist/core/component.js +52 -0
- package/dist/core/effects.d.ts +10 -0
- package/dist/core/effects.js +34 -0
- package/dist/core/state.d.ts +21 -0
- package/dist/{hyperapp-is/core → core}/state.js +15 -20
- package/dist/dom/dialog.d.ts +6 -0
- package/dist/dom/dialog.js +85 -0
- package/dist/dom/utils.d.ts +15 -0
- package/dist/dom/utils.js +19 -0
- package/dist/index.d.ts +13 -0
- package/dist/index.js +10 -0
- package/dist/services/google.d.ts +69 -0
- package/dist/services/google.js +170 -0
- package/package.json +13 -39
- package/dist/hyperapp-is/animation/raf.js +0 -209
- package/dist/hyperapp-is/animationView/carousel.d.ts +0 -48
- package/dist/hyperapp-is/animationView/carousel.js +0 -461
- package/dist/hyperapp-is/core/component.d.ts +0 -65
- package/dist/hyperapp-is/core/component.js +0 -242
- package/dist/hyperapp-is/core/navigator.d.ts +0 -115
- package/dist/hyperapp-is/core/navigator.js +0 -615
- package/dist/hyperapp-is/core/state.d.ts +0 -27
- package/dist/hyperapp-is/dom/utils.d.ts +0 -37
- package/dist/hyperapp-is/dom/utils.js +0 -69
- package/dist/hyperapp-is/index.d.ts +0 -16
- package/dist/hyperapp-is/index.js +0 -10
- package/dist/hyperapp-is/services/google.d.ts +0 -89
- package/dist/hyperapp-is/services/google.js +0 -178
|
@@ -1,461 +0,0 @@
|
|
|
1
|
-
// hyperapp-is / animationView / carousel.ts
|
|
2
|
-
import { getValue, setValue, createLocalKey } from "../core/state";
|
|
3
|
-
import { el, deleteKeys } from "../core/component";
|
|
4
|
-
import { RAFTask } from "../animation/raf";
|
|
5
|
-
// ---------- ---------- ---------- ---------- ----------
|
|
6
|
-
// vnodes
|
|
7
|
-
// ---------- ---------- ---------- ---------- ----------
|
|
8
|
-
const div = el("div");
|
|
9
|
-
const ul = el("ul");
|
|
10
|
-
const li = el("li");
|
|
11
|
-
const button = el("button");
|
|
12
|
-
// ---------- ---------- ---------- ---------- ----------
|
|
13
|
-
// Carousel Component
|
|
14
|
-
// ---------- ---------- ---------- ---------- ----------
|
|
15
|
-
/**
|
|
16
|
-
* Carousel Component
|
|
17
|
-
*/
|
|
18
|
-
export const Carousel = function (props, children) {
|
|
19
|
-
var _a;
|
|
20
|
-
const { state, id, keyNames, controlButton, controlBar, skipSpeedRate } = props;
|
|
21
|
-
// get task
|
|
22
|
-
const task = getValue(state, keyNames, [])
|
|
23
|
-
.find(task => task.id === id);
|
|
24
|
-
// get carouselState and carouselController
|
|
25
|
-
const param = (_a = task === null || task === void 0 ? void 0 : task.extension) === null || _a === void 0 ? void 0 : _a.carouselState;
|
|
26
|
-
const controller = task === null || task === void 0 ? void 0 : task.extension.carouselController;
|
|
27
|
-
// get index
|
|
28
|
-
const index = (param === null || param === void 0 ? void 0 : param.reportPageIndex)
|
|
29
|
-
? getValue(state, param.reportPageIndex, 0)
|
|
30
|
-
: getValue(state, [createLocalKey(id), "reportPageIndex"], 0);
|
|
31
|
-
// children
|
|
32
|
-
const items = Array.isArray(children) ? children : [children];
|
|
33
|
-
// ---------- ---------- ----------
|
|
34
|
-
// action_mouseenter
|
|
35
|
-
// ---------- ---------- ----------
|
|
36
|
-
const action_mouseenter = (state) => {
|
|
37
|
-
const task = getValue(state, keyNames, [])
|
|
38
|
-
.find(task => task.id === id);
|
|
39
|
-
if (!task)
|
|
40
|
-
return state;
|
|
41
|
-
// 一時停止
|
|
42
|
-
task.paused = true;
|
|
43
|
-
return state;
|
|
44
|
-
};
|
|
45
|
-
// ---------- ---------- ----------
|
|
46
|
-
// action_mouseleave
|
|
47
|
-
// ---------- ---------- ----------
|
|
48
|
-
const action_mouseleave = (state) => {
|
|
49
|
-
const task = getValue(state, keyNames, [])
|
|
50
|
-
.find(task => task.id === id);
|
|
51
|
-
if (!task)
|
|
52
|
-
return state;
|
|
53
|
-
// 一時停止解除
|
|
54
|
-
task.paused = false;
|
|
55
|
-
return state;
|
|
56
|
-
};
|
|
57
|
-
// ---------- ---------- ----------
|
|
58
|
-
// action_prevPage
|
|
59
|
-
// ---------- ---------- ----------
|
|
60
|
-
const action_prevPage = (state) => {
|
|
61
|
-
const task = getValue(state, keyNames, [])
|
|
62
|
-
.find(task => task.id === id);
|
|
63
|
-
if (!task)
|
|
64
|
-
return state;
|
|
65
|
-
controller.step(task, -1, skipSpeedRate !== null && skipSpeedRate !== void 0 ? skipSpeedRate : 0.3);
|
|
66
|
-
return state;
|
|
67
|
-
};
|
|
68
|
-
// ---------- ---------- ----------
|
|
69
|
-
// action_nextPage
|
|
70
|
-
// ---------- ---------- ----------
|
|
71
|
-
const action_nextPage = (state) => {
|
|
72
|
-
const task = getValue(state, keyNames, [])
|
|
73
|
-
.find(task => task.id === id);
|
|
74
|
-
if (!task)
|
|
75
|
-
return state;
|
|
76
|
-
controller.step(task, 1, skipSpeedRate !== null && skipSpeedRate !== void 0 ? skipSpeedRate : 0.3);
|
|
77
|
-
return state;
|
|
78
|
-
};
|
|
79
|
-
// ---------- ---------- ----------
|
|
80
|
-
// action_controlBarClick
|
|
81
|
-
// ---------- ---------- ----------
|
|
82
|
-
const action_ControlBarClick = (state, absoluteIndex) => {
|
|
83
|
-
var _a;
|
|
84
|
-
const task = getValue(state, keyNames, [])
|
|
85
|
-
.find(task => task.id === id);
|
|
86
|
-
if (!task)
|
|
87
|
-
return state;
|
|
88
|
-
const param = (_a = task.extension) === null || _a === void 0 ? void 0 : _a.carouselState;
|
|
89
|
-
if (!param)
|
|
90
|
-
return state;
|
|
91
|
-
controller.moveTo(task, absoluteIndex, skipSpeedRate !== null && skipSpeedRate !== void 0 ? skipSpeedRate : 0.3);
|
|
92
|
-
return state;
|
|
93
|
-
};
|
|
94
|
-
// ---------- ---------- ----------
|
|
95
|
-
// VNode
|
|
96
|
-
// ---------- ---------- ----------
|
|
97
|
-
return div({
|
|
98
|
-
...deleteKeys(props, "state", "keyNames")
|
|
99
|
-
}, ul({
|
|
100
|
-
onmouseenter: action_mouseenter,
|
|
101
|
-
onmouseleave: action_mouseleave
|
|
102
|
-
}, items.map(item => li({}, item))),
|
|
103
|
-
// controlButton, controlBar
|
|
104
|
-
(controlButton || controlBar) ? div({}, controlButton
|
|
105
|
-
? button({ onclick: action_prevPage }, "<")
|
|
106
|
-
: null, controlBar
|
|
107
|
-
? ul({}, items.map((_, i) => li({
|
|
108
|
-
class: i === index && "select",
|
|
109
|
-
onclick: [action_ControlBarClick, i]
|
|
110
|
-
},
|
|
111
|
-
// param が取れない場合、選択なしにする
|
|
112
|
-
param
|
|
113
|
-
? i === index ? "◉" : "・"
|
|
114
|
-
: "・")))
|
|
115
|
-
: null, controlButton
|
|
116
|
-
? button({ onclick: action_nextPage }, ">")
|
|
117
|
-
: null) : null);
|
|
118
|
-
};
|
|
119
|
-
// ---------- ---------- ---------- ---------- ----------
|
|
120
|
-
// effect_InitCarousel
|
|
121
|
-
// ---------- ---------- ---------- ---------- ----------
|
|
122
|
-
/**
|
|
123
|
-
* カルーセルを初期化し起動するエフェクト
|
|
124
|
-
*/
|
|
125
|
-
export const effect_InitCarousel = function (keyNames, carouselState) {
|
|
126
|
-
return (dispatch) => {
|
|
127
|
-
// どうしても画像ロードを待つ必要があるため、非同期処理に閉じ込めます
|
|
128
|
-
(async () => {
|
|
129
|
-
var _a, _b;
|
|
130
|
-
// CarouselState, easing
|
|
131
|
-
const param = carouselState;
|
|
132
|
-
const easing = (_a = param.easing) !== null && _a !== void 0 ? _a : ((t) => t);
|
|
133
|
-
// check dom
|
|
134
|
-
const div = document.getElementById(param.id);
|
|
135
|
-
if (!div)
|
|
136
|
-
return;
|
|
137
|
-
const ul = div.querySelector("ul");
|
|
138
|
-
if (!ul)
|
|
139
|
-
return;
|
|
140
|
-
// cloneNode className
|
|
141
|
-
const cloneClass = `${param.id}_clone`;
|
|
142
|
-
// clear cloneNodes
|
|
143
|
-
const children = Array.from(ul.children)
|
|
144
|
-
.filter((li, i) => {
|
|
145
|
-
if (li.classList.contains(cloneClass)) {
|
|
146
|
-
li.remove();
|
|
147
|
-
return false;
|
|
148
|
-
}
|
|
149
|
-
li.setAttribute("absoluteIndex", `${i}`); // もう面倒だから、DOMに絶対値情報保存する
|
|
150
|
-
return true;
|
|
151
|
-
});
|
|
152
|
-
if (!children || children.length === 0)
|
|
153
|
-
return;
|
|
154
|
-
// 画像読み込み待機
|
|
155
|
-
const waitImages = async () => {
|
|
156
|
-
const images = Array.from(ul.querySelectorAll("img"));
|
|
157
|
-
return Promise.all(images.map(img => {
|
|
158
|
-
if (img.complete)
|
|
159
|
-
return Promise.resolve();
|
|
160
|
-
return new Promise(resolve => {
|
|
161
|
-
img.onload = () => resolve();
|
|
162
|
-
img.onerror = () => resolve();
|
|
163
|
-
});
|
|
164
|
-
}));
|
|
165
|
-
};
|
|
166
|
-
await waitImages();
|
|
167
|
-
// get widths (幅 + Margin)
|
|
168
|
-
const widths = children.map(child => {
|
|
169
|
-
const width = child.getBoundingClientRect().width;
|
|
170
|
-
const style = getComputedStyle(child);
|
|
171
|
-
const marginLeft = parseFloat(style.marginLeft);
|
|
172
|
-
const marginRight = parseFloat(style.marginRight);
|
|
173
|
-
return width + marginLeft + marginRight;
|
|
174
|
-
});
|
|
175
|
-
// get ul gap
|
|
176
|
-
const ulStyle = getComputedStyle(ul);
|
|
177
|
-
const gap = parseFloat(ulStyle.columnGap || ulStyle.gap || "0");
|
|
178
|
-
const ulGap = isNaN(gap) ? 0 : gap;
|
|
179
|
-
// reportIndex path
|
|
180
|
-
const reportPageIndex = (_b = param.reportPageIndex) !== null && _b !== void 0 ? _b : [createLocalKey(param.id), "reportPageIndex"];
|
|
181
|
-
// dispatch
|
|
182
|
-
dispatch((state) => {
|
|
183
|
-
// ---------- ---------- ----------
|
|
184
|
-
// CarouselPrivateState
|
|
185
|
-
// ---------- ---------- ----------
|
|
186
|
-
const privateParam = {
|
|
187
|
-
ul,
|
|
188
|
-
step: 0,
|
|
189
|
-
index: 0,
|
|
190
|
-
startOffset: 0,
|
|
191
|
-
targetOffset: 0,
|
|
192
|
-
currentOffset: 0,
|
|
193
|
-
cloneNodes: []
|
|
194
|
-
};
|
|
195
|
-
// ---------- ---------- ----------
|
|
196
|
-
// function getCurrentState
|
|
197
|
-
// ---------- ---------- ----------
|
|
198
|
-
/**
|
|
199
|
-
* 相対、絶対インデックスの取得
|
|
200
|
-
* 先頭オフセット値の取得
|
|
201
|
-
* 入れ替えが必要な DOM の数を取得
|
|
202
|
-
*/
|
|
203
|
-
const getCurrentState = () => {
|
|
204
|
-
let relativeIndex = -1;
|
|
205
|
-
let absoluteIndex = -1;
|
|
206
|
-
let offset = 0;
|
|
207
|
-
for (let i = 0, width = offset; i < privateParam.ul.children.length; i++) {
|
|
208
|
-
const li = privateParam.ul.children[i];
|
|
209
|
-
const index = Number(li.getAttribute("absoluteIndex"));
|
|
210
|
-
if (Math.abs(privateParam.currentOffset) >= width) {
|
|
211
|
-
relativeIndex = i;
|
|
212
|
-
absoluteIndex = index;
|
|
213
|
-
offset = privateParam.currentOffset + width;
|
|
214
|
-
}
|
|
215
|
-
// next
|
|
216
|
-
width += widths[absoluteIndex];
|
|
217
|
-
if (i !== 0)
|
|
218
|
-
width += ulGap;
|
|
219
|
-
}
|
|
220
|
-
return {
|
|
221
|
-
relativeIndex: relativeIndex,
|
|
222
|
-
absoluteIndex: absoluteIndex,
|
|
223
|
-
offset: offset,
|
|
224
|
-
toggleCount: privateParam.step < 0
|
|
225
|
-
? Math.abs(privateParam.step) - relativeIndex
|
|
226
|
-
: relativeIndex
|
|
227
|
-
};
|
|
228
|
-
}; // end getCurrentState
|
|
229
|
-
// ---------- ---------- ----------
|
|
230
|
-
// controller
|
|
231
|
-
// ---------- ---------- ----------
|
|
232
|
-
const controller = {
|
|
233
|
-
// ---------- ---------- ----------
|
|
234
|
-
// controller.step
|
|
235
|
-
// ---------- ---------- ----------
|
|
236
|
-
step: (rafTask, delta, skipSpeedRate) => {
|
|
237
|
-
// 一時停止
|
|
238
|
-
const paused = rafTask.paused;
|
|
239
|
-
rafTask.paused = true;
|
|
240
|
-
// result
|
|
241
|
-
return new Promise((resolve, reject) => {
|
|
242
|
-
// currentState
|
|
243
|
-
const currentState = getCurrentState();
|
|
244
|
-
// delete cloneNodes
|
|
245
|
-
privateParam.cloneNodes.forEach(node => node.remove());
|
|
246
|
-
privateParam.cloneNodes = [];
|
|
247
|
-
// DOM の入れ替え
|
|
248
|
-
for (let i = 0; i < currentState.toggleCount; i++) {
|
|
249
|
-
const node = privateParam.step < 0
|
|
250
|
-
? privateParam.ul.lastChild
|
|
251
|
-
: privateParam.ul.firstChild;
|
|
252
|
-
if (node) {
|
|
253
|
-
if (privateParam.step < 0) {
|
|
254
|
-
privateParam.ul.insertBefore(node, privateParam.ul.firstChild);
|
|
255
|
-
}
|
|
256
|
-
else {
|
|
257
|
-
privateParam.ul.appendChild(node);
|
|
258
|
-
}
|
|
259
|
-
}
|
|
260
|
-
}
|
|
261
|
-
// create cloneNodes
|
|
262
|
-
let cloneWidth = 0;
|
|
263
|
-
for (let i = 0; i < Math.abs(delta); i++) {
|
|
264
|
-
const index = delta < 0
|
|
265
|
-
? privateParam.ul.children.length - 1 - i
|
|
266
|
-
: i;
|
|
267
|
-
const cloneNode = privateParam.ul.children[index].cloneNode(true);
|
|
268
|
-
cloneNode.classList.add(cloneClass);
|
|
269
|
-
privateParam.cloneNodes.push(cloneNode);
|
|
270
|
-
if (delta < 0) {
|
|
271
|
-
privateParam.ul.insertBefore(cloneNode, privateParam.ul.firstChild);
|
|
272
|
-
}
|
|
273
|
-
else {
|
|
274
|
-
privateParam.ul.appendChild(cloneNode);
|
|
275
|
-
}
|
|
276
|
-
// get width
|
|
277
|
-
const absoluteIndex = Number(cloneNode.getAttribute("absoluteIndex"));
|
|
278
|
-
cloneWidth += widths[absoluteIndex];
|
|
279
|
-
// add gap
|
|
280
|
-
if (i !== 0)
|
|
281
|
-
cloneWidth += ulGap;
|
|
282
|
-
} // end create cloneNodes
|
|
283
|
-
// privateParamの調整
|
|
284
|
-
privateParam.step = delta;
|
|
285
|
-
privateParam.index = ((currentState.absoluteIndex + delta) % children.length + children.length) % children.length;
|
|
286
|
-
privateParam.startOffset = delta < 0
|
|
287
|
-
? currentState.offset - cloneWidth
|
|
288
|
-
: currentState.offset;
|
|
289
|
-
privateParam.currentOffset = privateParam.startOffset;
|
|
290
|
-
privateParam.targetOffset = delta < 0
|
|
291
|
-
? 0
|
|
292
|
-
: -cloneWidth;
|
|
293
|
-
// スタイル適用
|
|
294
|
-
privateParam.ul.style.transform = `translateX(${privateParam.currentOffset}px)`;
|
|
295
|
-
// newTask
|
|
296
|
-
const newTask = new RAFTask({
|
|
297
|
-
id: `${param.id}_step`,
|
|
298
|
-
duration: rafTask.duration * (skipSpeedRate !== null && skipSpeedRate !== void 0 ? skipSpeedRate : 0.1),
|
|
299
|
-
action,
|
|
300
|
-
finish: (state, rafTask) => {
|
|
301
|
-
rafTask.paused = paused;
|
|
302
|
-
const res = finish(state, rafTask);
|
|
303
|
-
const newState = Array.isArray(res)
|
|
304
|
-
? res[0]
|
|
305
|
-
: res;
|
|
306
|
-
// 一時停止状況の復元
|
|
307
|
-
rafTask.paused = paused;
|
|
308
|
-
resolve(rafTask);
|
|
309
|
-
return newState;
|
|
310
|
-
},
|
|
311
|
-
}); // end newTask
|
|
312
|
-
// dispatch
|
|
313
|
-
requestAnimationFrame(() => dispatch((state) => {
|
|
314
|
-
const tasks = getValue(state, keyNames, [])
|
|
315
|
-
.filter(task => task.id !== `${param.id}_step` && task.id !== param.id)
|
|
316
|
-
.concat(newTask);
|
|
317
|
-
return setValue(state, keyNames, tasks);
|
|
318
|
-
}));
|
|
319
|
-
});
|
|
320
|
-
}, // end controller.step
|
|
321
|
-
// ---------- ---------- ----------
|
|
322
|
-
// controller.moveTo
|
|
323
|
-
// ---------- ---------- ----------
|
|
324
|
-
moveTo: (rafTask, index, skipSpeedRate) => {
|
|
325
|
-
return controller.step(rafTask, index - getCurrentState().absoluteIndex, skipSpeedRate);
|
|
326
|
-
}
|
|
327
|
-
}; // end controller
|
|
328
|
-
// ---------- ---------- ----------
|
|
329
|
-
// task_action
|
|
330
|
-
// ---------- ---------- ----------
|
|
331
|
-
const action = (state, rafTask) => {
|
|
332
|
-
if (!privateParam.ul.isConnected)
|
|
333
|
-
return state;
|
|
334
|
-
if (rafTask.paused)
|
|
335
|
-
return state;
|
|
336
|
-
// privateParam.currentOffset の調整
|
|
337
|
-
privateParam.currentOffset = privateParam.startOffset
|
|
338
|
-
+ (privateParam.targetOffset - privateParam.startOffset)
|
|
339
|
-
* easing(rafTask.progress);
|
|
340
|
-
// style 適用
|
|
341
|
-
privateParam.ul.style.transform = `translateX(${privateParam.currentOffset}px)`;
|
|
342
|
-
return [state, (dispatch) => {
|
|
343
|
-
// action 割り込み
|
|
344
|
-
const fn = param.action;
|
|
345
|
-
if (fn)
|
|
346
|
-
requestAnimationFrame(() => dispatch((state) => [fn, rafTask]));
|
|
347
|
-
}];
|
|
348
|
-
};
|
|
349
|
-
// ---------- ---------- ----------
|
|
350
|
-
// task_finish
|
|
351
|
-
// ---------- ---------- ----------
|
|
352
|
-
const finish = (state, rafTask) => {
|
|
353
|
-
if (!privateParam.ul.isConnected)
|
|
354
|
-
return state;
|
|
355
|
-
// set reportPageIndex
|
|
356
|
-
let newState = setValue(state, reportPageIndex, privateParam.index);
|
|
357
|
-
// delete cloneNodes
|
|
358
|
-
privateParam.cloneNodes.forEach(node => node.remove());
|
|
359
|
-
privateParam.cloneNodes = [];
|
|
360
|
-
// DOM の入れ替え
|
|
361
|
-
for (let i = 0; i < Math.abs(privateParam.step); i++) {
|
|
362
|
-
const node = privateParam.step < 0
|
|
363
|
-
? privateParam.ul.lastChild
|
|
364
|
-
: privateParam.ul.firstChild;
|
|
365
|
-
if (privateParam.step < 0) {
|
|
366
|
-
privateParam.ul.insertBefore(node, privateParam.ul.firstChild);
|
|
367
|
-
}
|
|
368
|
-
else {
|
|
369
|
-
privateParam.ul.appendChild(node);
|
|
370
|
-
}
|
|
371
|
-
}
|
|
372
|
-
// set index
|
|
373
|
-
privateParam.step = param.step;
|
|
374
|
-
privateParam.index = ((privateParam.index + privateParam.step) % children.length + children.length) % children.length;
|
|
375
|
-
// add cloneNodes
|
|
376
|
-
let cloneWidth = 0;
|
|
377
|
-
for (let i = 0; i < Math.abs(privateParam.step); i++) {
|
|
378
|
-
const index = privateParam.step < 0
|
|
379
|
-
? privateParam.ul.children.length - 1 - i
|
|
380
|
-
: i;
|
|
381
|
-
const cloneNode = privateParam.ul.children[index].cloneNode(true);
|
|
382
|
-
cloneNode.classList.add(cloneClass);
|
|
383
|
-
privateParam.cloneNodes.push(cloneNode);
|
|
384
|
-
if (privateParam.step < 0) {
|
|
385
|
-
privateParam.ul.insertBefore(cloneNode, privateParam.ul.firstChild);
|
|
386
|
-
}
|
|
387
|
-
else {
|
|
388
|
-
privateParam.ul.appendChild(cloneNode);
|
|
389
|
-
}
|
|
390
|
-
// get width
|
|
391
|
-
const absoluteIndex = Number(cloneNode.getAttribute("absoluteIndex"));
|
|
392
|
-
cloneWidth += widths[absoluteIndex];
|
|
393
|
-
// add gap
|
|
394
|
-
if (i !== 0)
|
|
395
|
-
cloneWidth += ulGap;
|
|
396
|
-
}
|
|
397
|
-
// privateParam の調整
|
|
398
|
-
privateParam.startOffset = privateParam.step < 0
|
|
399
|
-
? -cloneWidth
|
|
400
|
-
: 0;
|
|
401
|
-
privateParam.targetOffset = privateParam.step < 0
|
|
402
|
-
? 0
|
|
403
|
-
: -cloneWidth;
|
|
404
|
-
privateParam.currentOffset = privateParam.startOffset;
|
|
405
|
-
// set dom
|
|
406
|
-
privateParam.ul.style.transform = `translateX(${privateParam.currentOffset}px)`;
|
|
407
|
-
newState = setValue(newState, keyNames, getValue(newState, keyNames, [])
|
|
408
|
-
.filter(task => task.id !== param.id)
|
|
409
|
-
.concat(createTask()));
|
|
410
|
-
return [newState, (dispatch) => {
|
|
411
|
-
// finish 割り込み
|
|
412
|
-
const fn = param.finish;
|
|
413
|
-
if (fn)
|
|
414
|
-
requestAnimationFrame(() => dispatch((state) => [fn, rafTask]));
|
|
415
|
-
}];
|
|
416
|
-
};
|
|
417
|
-
// ---------- ---------- ----------
|
|
418
|
-
// createTask
|
|
419
|
-
// ---------- ---------- ----------
|
|
420
|
-
const createTask = () => {
|
|
421
|
-
var _a, _b, _c;
|
|
422
|
-
return new RAFTask({
|
|
423
|
-
id: param.id,
|
|
424
|
-
groupID: param.groupID,
|
|
425
|
-
duration: (_a = param.duration) !== null && _a !== void 0 ? _a : 1000,
|
|
426
|
-
delay: (_b = param.delay) !== null && _b !== void 0 ? _b : 2000,
|
|
427
|
-
action,
|
|
428
|
-
finish,
|
|
429
|
-
priority: (_c = param.priority) !== null && _c !== void 0 ? _c : 0,
|
|
430
|
-
extension: {
|
|
431
|
-
...param.extension,
|
|
432
|
-
carouselState: param,
|
|
433
|
-
carouselController: controller
|
|
434
|
-
}
|
|
435
|
-
});
|
|
436
|
-
}; // end createTask
|
|
437
|
-
// ---------- ---------- ----------
|
|
438
|
-
// startTask
|
|
439
|
-
// ---------- ---------- ----------
|
|
440
|
-
const startTask = new RAFTask({
|
|
441
|
-
id: param.id,
|
|
442
|
-
groupID: param.groupID,
|
|
443
|
-
duration: 0,
|
|
444
|
-
delay: 0,
|
|
445
|
-
action: (state, rafTask) => state,
|
|
446
|
-
finish,
|
|
447
|
-
extension: {
|
|
448
|
-
carouselState: param,
|
|
449
|
-
carouselController: controller
|
|
450
|
-
}
|
|
451
|
-
});
|
|
452
|
-
// ---------- ---------- ----------
|
|
453
|
-
// result
|
|
454
|
-
// ---------- ---------- ----------
|
|
455
|
-
return setValue(state, keyNames, getValue(state, keyNames, [])
|
|
456
|
-
.filter(task => task.id !== param.id)
|
|
457
|
-
.concat(startTask));
|
|
458
|
-
}); // end dispatch
|
|
459
|
-
})(); // end sync
|
|
460
|
-
}; // end result
|
|
461
|
-
}; // end effect
|
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
import { VNode, Effect } from "hyperapp";
|
|
2
|
-
import { Keys_String, Keys_ArrayString } from "./state";
|
|
3
|
-
/**
|
|
4
|
-
* h 関数のラッパー
|
|
5
|
-
* hが競合する可能性があるので作成した
|
|
6
|
-
*/
|
|
7
|
-
export declare const el: <S = any>(tag: string) => (props?: {
|
|
8
|
-
[key: string]: any;
|
|
9
|
-
}, ...children: any[]) => VNode<S>;
|
|
10
|
-
/**
|
|
11
|
-
* アクションを結合して結果を返す
|
|
12
|
-
*/
|
|
13
|
-
export declare const concatAction: <S, E>(action: undefined | ((state: S, e: E) => S | [S, Effect<S>]), newState: S, e: E) => S | [S, Effect<S>];
|
|
14
|
-
/**
|
|
15
|
-
* props から classList を取得
|
|
16
|
-
*/
|
|
17
|
-
export declare const getClassList: (props: {
|
|
18
|
-
[key: string]: any;
|
|
19
|
-
}) => string[];
|
|
20
|
-
/**
|
|
21
|
-
* props から不要なキーを削除する
|
|
22
|
-
*/
|
|
23
|
-
export declare const deleteKeys: <T extends Record<string, any>>(props: T, ...keys: (keyof T)[]) => Omit<T, (typeof keys)[number]>;
|
|
24
|
-
/**
|
|
25
|
-
* ステート内の文字とmatchした時、VNodeを返す
|
|
26
|
-
*/
|
|
27
|
-
export declare const Route: <S>(props: {
|
|
28
|
-
state: S;
|
|
29
|
-
keyNames: Keys_String;
|
|
30
|
-
match: string;
|
|
31
|
-
}, children: any) => VNode<S> | null;
|
|
32
|
-
/**
|
|
33
|
-
* クリックで、クラス名 select をトグルするボタン
|
|
34
|
-
*/
|
|
35
|
-
export declare const SelectButton: <S>(props: {
|
|
36
|
-
state: S;
|
|
37
|
-
keyNames: Keys_ArrayString;
|
|
38
|
-
id: string;
|
|
39
|
-
reverse?: boolean;
|
|
40
|
-
[key: string]: any;
|
|
41
|
-
}, children: any) => VNode<S>;
|
|
42
|
-
/**
|
|
43
|
-
* クリックで、クラス名 select を排他的に選択するボタン
|
|
44
|
-
*/
|
|
45
|
-
export declare const OptionButton: <S>(props: {
|
|
46
|
-
state: S;
|
|
47
|
-
keyNames: Keys_String;
|
|
48
|
-
id: string;
|
|
49
|
-
reverse?: boolean;
|
|
50
|
-
[key: string]: any;
|
|
51
|
-
}, children: any) => VNode<S>;
|
|
52
|
-
/**
|
|
53
|
-
* 履歴付きインプット
|
|
54
|
-
* localState: { histories: string[] }
|
|
55
|
-
*
|
|
56
|
-
* @returns {VNode<S>[]} - [HTMLInputElement, HTMLDataListElement]
|
|
57
|
-
*/
|
|
58
|
-
export declare const HistoryInput: <S>(props: {
|
|
59
|
-
state: S;
|
|
60
|
-
id: string;
|
|
61
|
-
keyNames: Keys_String;
|
|
62
|
-
historyLimit?: number;
|
|
63
|
-
afterRender?: (state: S, localState: Record<string, any>, vnode: VNode<S>[]) => VNode<S>[];
|
|
64
|
-
[key: string]: any;
|
|
65
|
-
}) => VNode<S>[];
|