質問編集履歴

2

試してみたことの追加

2018/12/21 19:18

投稿

kazoogon
kazoogon

スコア281

test CHANGED
File without changes
test CHANGED
@@ -223,3 +223,223 @@
223
223
  }
224
224
 
225
225
  ```
226
+
227
+ 試してみたこと
228
+
229
+ ---
230
+
231
+ defaultでdisplay: none; にし、mount関数内の操作でdisplay: '';にする
232
+
233
+ (<memo>display: blockではfade out animationの動作はしない)
234
+
235
+ ```
236
+
237
+ //html部分
238
+
239
+ <button onclick="{success}" class="btn">Open</button>
240
+
241
+
242
+
243
+ // displayの追加
244
+
245
+ <div class="modal {show: ui.success} {hide: !ui.success} {none: ui.display}">saved!</div>
246
+
247
+ ```
248
+
249
+ ```
250
+
251
+ //JS部分
252
+
253
+ //mount関数追加
254
+
255
+ this.on('mount', function(){
256
+
257
+ setTimeout(function(){
258
+
259
+ this.ui.display = false;
260
+
261
+ this.update();
262
+
263
+ }.bind(this),2000);
264
+
265
+ });
266
+
267
+
268
+
269
+ this.ui = {
270
+
271
+ success: false,
272
+
273
+ show: false,
274
+
275
+ display: true, //追加
276
+
277
+ };
278
+
279
+
280
+
281
+ function show(){
282
+
283
+ setTimeout(function(){
284
+
285
+ this.ui.show = true;
286
+
287
+ this.update();
288
+
289
+ }.bind(this), 1);
290
+
291
+ }
292
+
293
+
294
+
295
+ success(){
296
+
297
+ this.ui.success = true;
298
+
299
+ this.update();
300
+
301
+
302
+
303
+ show.call(this);
304
+
305
+ }
306
+
307
+
308
+
309
+ document.body.addEventListener("click", function(e) {
310
+
311
+ if(e.target.className !== "btn") {
312
+
313
+ this.ui.success = false;
314
+
315
+ this.ui.show = false;
316
+
317
+ this.update();
318
+
319
+ }
320
+
321
+ }.bind(this), false);
322
+
323
+ ```
324
+
325
+ ```
326
+
327
+ //CSS部分
328
+
329
+ .modal {
330
+
331
+ width: 0px;
332
+
333
+ height: 0px;
334
+
335
+ position: fixed;
336
+
337
+ top: 50%;
338
+
339
+ left: 50%;
340
+
341
+ transform: translate(-50%, -50%);
342
+
343
+ overflow: hidden;
344
+
345
+ box-shadow: 2px 2px 8px #aaa;
346
+
347
+ background: white;
348
+
349
+ }
350
+
351
+
352
+
353
+ .show {
354
+
355
+ width: 300px;
356
+
357
+ height: 60px;
358
+
359
+ animation: fadein 2s ease-in-out;
360
+
361
+ }
362
+
363
+
364
+
365
+ .hide {
366
+
367
+ width: 0px;
368
+
369
+ height: 0px;
370
+
371
+ animation: fadeout 2s ease-in-out;
372
+
373
+ }
374
+
375
+
376
+
377
+ //追加
378
+
379
+ .none {
380
+
381
+ display: none;
382
+
383
+ }
384
+
385
+
386
+
387
+ @keyframes fadein {
388
+
389
+ 0%{
390
+
391
+ opacity:0;
392
+
393
+ width: 0px;
394
+
395
+ height:0px;
396
+
397
+ }
398
+
399
+ 5% {
400
+
401
+ width: 300px;
402
+
403
+ height: 60px;
404
+
405
+ }
406
+
407
+ 100% {
408
+
409
+ opacity:1;
410
+
411
+ }
412
+
413
+ }
414
+
415
+
416
+
417
+ @keyframes fadeout {
418
+
419
+ 0% {
420
+
421
+ opacity: 1;
422
+
423
+ width: 300px;
424
+
425
+ height: 60px;
426
+
427
+ }
428
+
429
+ 99%{
430
+
431
+ width: 300px;
432
+
433
+ height: 60px;
434
+
435
+ }
436
+
437
+ 100% {
438
+
439
+ opacity:0;
440
+
441
+ }
442
+
443
+ }
444
+
445
+ ```

1

環境説明の修正

2018/12/21 19:18

投稿

kazoogon
kazoogon

スコア281

test CHANGED
File without changes
test CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  ---
4
4
 
5
- Riot.jsを使用しfrontサイドを実装(今回の質問はRiot.js触ったこと無い方でもかるかと思います)
5
+ Riot.jsを使用しfrontサイドを実装(Riot.js触った事ない方でも大体何をしているはわかるかと思いますが、riot.js経験者でしたら大歓迎です)
6
6
 
7
7
 
8
8