質問編集履歴
1
修正
test
CHANGED
File without changes
|
test
CHANGED
@@ -164,354 +164,362 @@
|
|
164
164
|
|
165
165
|
modalImage.classList.remove('show');
|
166
166
|
|
167
|
+
modalPrev.style.visibility = 'hidden';
|
168
|
+
|
169
|
+
modalNext.style.visibility = 'hidden';
|
170
|
+
|
167
171
|
setTimeout(function () {
|
168
172
|
|
169
173
|
modalImage.classList.remove('off');
|
170
174
|
|
171
175
|
modalImage.classList.add('show');
|
172
176
|
|
177
|
+
let prevNum = parseInt(modalImage.getAttribute('data-num'));
|
178
|
+
|
179
|
+
modalNext.style.visibility = 'visible';
|
180
|
+
|
181
|
+
if (!document.querySelector('[data-num="' + (prevNum - 2) + '"].on')) {
|
182
|
+
|
183
|
+
modalPrev.style.visibility = 'hidden';
|
184
|
+
|
185
|
+
modalNext.style.visibility = 'visible';
|
186
|
+
|
187
|
+
} else {
|
188
|
+
|
189
|
+
modalPrev.style.visibility = 'visible';
|
190
|
+
|
191
|
+
modalNext.style.visibility = 'visible';
|
192
|
+
|
193
|
+
}
|
194
|
+
|
195
|
+
let prevImg = document.querySelector('[data-num="' + (prevNum - 1) + '"].on'),
|
196
|
+
|
197
|
+
prevSrc = prevImg.getAttribute('data-src'),
|
198
|
+
|
199
|
+
prevCaption = prevImg.getAttribute('data-caption');
|
200
|
+
|
201
|
+
modalImage.src = prevSrc;
|
202
|
+
|
203
|
+
modalAside.textContent = prevCaption;
|
204
|
+
|
205
|
+
modalImage.dataset.num = prevNum - 1;
|
206
|
+
|
207
|
+
setTimeout(function () {
|
208
|
+
|
209
|
+
modalWrapper.classList.remove('spinner');
|
210
|
+
|
173
|
-
}, 200);
|
211
|
+
}, 200);
|
212
|
+
|
174
|
-
|
213
|
+
}, 300);
|
214
|
+
|
215
|
+
}
|
216
|
+
|
217
|
+
|
218
|
+
|
219
|
+
function next() {
|
220
|
+
|
175
|
-
|
221
|
+
document.body.style.overflowY = 'hidden', html.classList.add('is-fixed');
|
176
|
-
|
222
|
+
|
177
|
-
modal
|
223
|
+
modalWrapper.classList.add('spinner');
|
224
|
+
|
178
|
-
|
225
|
+
modalImage.classList.add('off');
|
226
|
+
|
179
|
-
|
227
|
+
modalImage.classList.remove('show');
|
180
|
-
|
228
|
+
|
181
|
-
|
229
|
+
modalPrev.style.visibility = 'hidden';
|
230
|
+
|
182
|
-
|
231
|
+
modalNext.style.visibility = 'hidden';
|
232
|
+
|
183
|
-
|
233
|
+
setTimeout(function () {
|
234
|
+
|
235
|
+
modalImage.classList.remove('off');
|
236
|
+
|
237
|
+
modalImage.classList.add('show');
|
238
|
+
|
239
|
+
let nextNum = parseInt(modalImage.getAttribute('data-num'));
|
184
240
|
|
185
241
|
modalPrev.style.visibility = 'visible';
|
186
242
|
|
243
|
+
if (!document.querySelector('[data-num="' + (nextNum + 2) + '"].on')) {
|
244
|
+
|
245
|
+
modalNext.style.visibility = 'hidden';
|
246
|
+
|
247
|
+
modalPrev.style.visibility = 'visible';
|
248
|
+
|
249
|
+
} else {
|
250
|
+
|
251
|
+
modalNext.style.visibility = 'visible';
|
252
|
+
|
253
|
+
modalPrev.style.visibility = 'visible';
|
254
|
+
|
255
|
+
}
|
256
|
+
|
257
|
+
let nextImg = document.querySelector('[data-num="' + (nextNum + 1) + '"].on'),
|
258
|
+
|
259
|
+
nextSrc = nextImg.getAttribute('data-src'),
|
260
|
+
|
261
|
+
nextCaption = nextImg.getAttribute('data-caption');
|
262
|
+
|
263
|
+
modalImage.src = nextSrc;
|
264
|
+
|
265
|
+
modalAside.textContent = nextCaption;
|
266
|
+
|
267
|
+
modalImage.dataset.num = nextNum + 1;
|
268
|
+
|
269
|
+
setTimeout(function () {
|
270
|
+
|
271
|
+
modalWrapper.classList.remove('spinner');
|
272
|
+
|
273
|
+
}, 200);
|
274
|
+
|
275
|
+
}, 300);
|
276
|
+
|
277
|
+
}
|
278
|
+
|
279
|
+
/* modal ------------------------------------------------ end */
|
280
|
+
|
281
|
+
});
|
282
|
+
|
283
|
+
|
284
|
+
|
285
|
+
if (!HTMLElement.prototype.swipe) {
|
286
|
+
|
287
|
+
Object.defineProperty(HTMLElement.prototype, "swipe", {
|
288
|
+
|
289
|
+
configurable: true,
|
290
|
+
|
291
|
+
enumerable: false,
|
292
|
+
|
293
|
+
writable: true,
|
294
|
+
|
295
|
+
value: function (direction, callback, sensitivity) {
|
296
|
+
|
297
|
+
const self = this;
|
298
|
+
|
299
|
+
const sens = Object.prototype.toString.call(sensitivity) !== '[object Number]' || sensitivity <= 0 ? 5 : sensitivity;
|
300
|
+
|
301
|
+
switch (direction) {
|
302
|
+
|
303
|
+
case 'left':
|
304
|
+
|
305
|
+
self.addEventListener('touchstart', function (event) {
|
306
|
+
|
307
|
+
self.removeEventListener("touchstart", null, false);
|
308
|
+
|
309
|
+
let position = event.changedTouches[0].pageX;
|
310
|
+
|
311
|
+
self.addEventListener('touchend', function (event) {
|
312
|
+
|
313
|
+
self.removeEventListener("touchend", null, false);
|
314
|
+
|
315
|
+
if (event.changedTouches[0].pageX < position - screen.width / sens) {
|
316
|
+
|
317
|
+
callback(self);
|
318
|
+
|
319
|
+
}
|
320
|
+
|
321
|
+
position = 0;
|
322
|
+
|
323
|
+
});
|
324
|
+
|
325
|
+
}, false);
|
326
|
+
|
327
|
+
break;
|
328
|
+
|
329
|
+
case 'right':
|
330
|
+
|
331
|
+
self.addEventListener('touchstart', function (event) {
|
332
|
+
|
333
|
+
self.removeEventListener("touchstart", null, false);
|
334
|
+
|
335
|
+
let position = event.changedTouches[0].pageX;
|
336
|
+
|
337
|
+
self.addEventListener('touchend', function (event) {
|
338
|
+
|
339
|
+
self.removeEventListener("touchend", null, false);
|
340
|
+
|
341
|
+
if (event.changedTouches[0].pageX > position + screen.width / sens) {
|
342
|
+
|
343
|
+
callback(self);
|
344
|
+
|
345
|
+
}
|
346
|
+
|
347
|
+
position = screen.width;
|
348
|
+
|
349
|
+
});
|
350
|
+
|
351
|
+
}, false);
|
352
|
+
|
353
|
+
break;
|
354
|
+
|
355
|
+
}
|
356
|
+
|
187
357
|
}
|
188
358
|
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
m
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
d
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
set
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
}
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
359
|
+
});
|
360
|
+
|
361
|
+
}
|
362
|
+
|
363
|
+
|
364
|
+
|
365
|
+
// これが動かない
|
366
|
+
|
367
|
+
if (!HTMLElement.prototype.drag) {
|
368
|
+
|
369
|
+
Object.defineProperty(HTMLElement.prototype, "drag", {
|
370
|
+
|
371
|
+
configurable: true,
|
372
|
+
|
373
|
+
enumerable: false,
|
374
|
+
|
375
|
+
writable: true,
|
376
|
+
|
377
|
+
value: function (direction, callback, sensitivity) {
|
378
|
+
|
379
|
+
const self = this;
|
380
|
+
|
381
|
+
const sens = Object.prototype.toString.call(sensitivity) !== '[object Number]' || sensitivity <= 0 ? 5 : sensitivity;
|
382
|
+
|
383
|
+
switch (direction) {
|
384
|
+
|
385
|
+
case 'left':
|
386
|
+
|
387
|
+
self.addEventListener('mousedown', function (event) {
|
388
|
+
|
389
|
+
self.removeEventListener("mousedown", null, false);
|
390
|
+
|
391
|
+
let position = event.pageX;
|
392
|
+
|
393
|
+
self.addEventListener('mouseup', function (event) {
|
394
|
+
|
395
|
+
self.removeEventListener("mouseup", null, false);
|
396
|
+
|
397
|
+
if (event.pageX < position - screen.width / sens) {
|
398
|
+
|
399
|
+
callback(self);
|
400
|
+
|
401
|
+
}
|
402
|
+
|
403
|
+
position = 0;
|
404
|
+
|
405
|
+
});
|
406
|
+
|
407
|
+
}, false);
|
408
|
+
|
409
|
+
break;
|
410
|
+
|
411
|
+
case 'right':
|
412
|
+
|
413
|
+
self.addEventListener('mousedown', function (event) {
|
414
|
+
|
415
|
+
self.removeEventListener("mousedown", null, false);
|
416
|
+
|
417
|
+
let position = event.pageX;
|
418
|
+
|
419
|
+
self.addEventListener('mouseup', function (event) {
|
420
|
+
|
421
|
+
self.removeEventListener("mouseup", null, false);
|
422
|
+
|
423
|
+
if (event.pageX > position + screen.width / sens) {
|
424
|
+
|
425
|
+
callback(self);
|
426
|
+
|
427
|
+
}
|
428
|
+
|
429
|
+
position = screen.width;
|
430
|
+
|
431
|
+
});
|
432
|
+
|
433
|
+
}, false);
|
434
|
+
|
435
|
+
break;
|
436
|
+
|
437
|
+
}
|
244
438
|
|
245
439
|
}
|
246
440
|
|
247
|
-
let nextImg = document.querySelector('[data-num="' + (nextNum + 1) + '"].on'),
|
248
|
-
|
249
|
-
nextSrc = nextImg.getAttribute('data-src'),
|
250
|
-
|
251
|
-
nextCaption = nextImg.getAttribute('data-caption');
|
252
|
-
|
253
|
-
setTimeout(function () {
|
254
|
-
|
255
|
-
modalImage.src = nextSrc;
|
256
|
-
|
257
|
-
}, 200);
|
258
|
-
|
259
|
-
modalAside.textContent = nextCaption;
|
260
|
-
|
261
|
-
modalImage.dataset.num = nextNum + 1;
|
262
|
-
|
263
|
-
setTimeout(function () {
|
264
|
-
|
265
|
-
modalWrapper.classList.remove('spinner');
|
266
|
-
|
267
|
-
}, 200);
|
268
|
-
|
269
|
-
}
|
270
|
-
|
271
|
-
/* modal ------------------------------------------------ end */
|
272
|
-
|
273
|
-
});
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
if (!HTMLElement.prototype.swipe) {
|
278
|
-
|
279
|
-
Object.defineProperty(HTMLElement.prototype, "swipe", {
|
280
|
-
|
281
|
-
configurable: true,
|
282
|
-
|
283
|
-
enumerable: false,
|
284
|
-
|
285
|
-
writable: true,
|
286
|
-
|
287
|
-
value: function (direction, callback, sensitivity) {
|
288
|
-
|
289
|
-
const self = this;
|
290
|
-
|
291
|
-
const sens = Object.prototype.toString.call(sensitivity) !== '[object Number]' || sensitivity <= 0 ? 5 : sensitivity;
|
292
|
-
|
293
|
-
switch (direction) {
|
294
|
-
|
295
|
-
case 'left':
|
296
|
-
|
297
|
-
self.addEventListener('touchstart', function (event) {
|
298
|
-
|
299
|
-
self.removeEventListener("touchstart", null, false);
|
300
|
-
|
301
|
-
let position = event.changedTouches[0].pageX;
|
302
|
-
|
303
|
-
self.addEventListener('touchend', function (event) {
|
304
|
-
|
305
|
-
self.removeEventListener("touchend", null, false);
|
306
|
-
|
307
|
-
if (event.changedTouches[0].pageX < position - screen.width / sens) {
|
308
|
-
|
309
|
-
callback(self);
|
310
|
-
|
311
|
-
}
|
312
|
-
|
313
|
-
position = 0;
|
314
|
-
|
315
|
-
});
|
316
|
-
|
317
|
-
}, false);
|
318
|
-
|
319
|
-
break;
|
320
|
-
|
321
|
-
case 'right':
|
322
|
-
|
323
|
-
self.addEventListener('touchstart', function (event) {
|
324
|
-
|
325
|
-
self.removeEventListener("touchstart", null, false);
|
326
|
-
|
327
|
-
let position = event.changedTouches[0].pageX;
|
328
|
-
|
329
|
-
self.addEventListener('touchend', function (event) {
|
330
|
-
|
331
|
-
self.removeEventListener("touchend", null, false);
|
332
|
-
|
333
|
-
if (event.changedTouches[0].pageX > position + screen.width / sens) {
|
334
|
-
|
335
|
-
callback(self);
|
336
|
-
|
337
|
-
}
|
338
|
-
|
339
|
-
position = screen.width;
|
340
|
-
|
341
|
-
});
|
342
|
-
|
343
|
-
}, false);
|
344
|
-
|
345
|
-
break;
|
346
|
-
|
347
|
-
}
|
348
|
-
|
349
|
-
}
|
350
|
-
|
351
441
|
});
|
352
442
|
|
353
443
|
}
|
354
444
|
|
355
445
|
|
356
446
|
|
357
|
-
|
358
|
-
|
359
|
-
|
360
|
-
|
361
|
-
|
362
|
-
|
363
|
-
|
364
|
-
|
365
|
-
|
366
|
-
|
367
|
-
|
368
|
-
|
369
|
-
|
370
|
-
|
371
|
-
|
372
|
-
|
373
|
-
|
374
|
-
|
375
|
-
|
376
|
-
|
377
|
-
|
378
|
-
|
379
|
-
|
380
|
-
|
381
|
-
|
382
|
-
|
383
|
-
|
384
|
-
|
385
|
-
|
386
|
-
|
387
|
-
|
388
|
-
|
389
|
-
|
390
|
-
|
391
|
-
|
392
|
-
|
393
|
-
|
394
|
-
|
395
|
-
|
396
|
-
|
397
|
-
|
398
|
-
|
399
|
-
|
400
|
-
|
401
|
-
|
402
|
-
|
403
|
-
|
404
|
-
|
405
|
-
self.addEventListener('mousedown', function (event) {
|
406
|
-
|
407
|
-
self.removeEventListener("mousedown", null, false);
|
408
|
-
|
409
|
-
let position = event.pageX;
|
410
|
-
|
411
|
-
self.addEventListener('mouseup', function (event) {
|
412
|
-
|
413
|
-
self.removeEventListener("mouseup", null, false);
|
414
|
-
|
415
|
-
if (event.pageX > position + screen.width / sens) {
|
416
|
-
|
417
|
-
callback(self);
|
418
|
-
|
419
|
-
}
|
420
|
-
|
421
|
-
position = screen.width;
|
422
|
-
|
423
|
-
});
|
424
|
-
|
425
|
-
}, false);
|
426
|
-
|
427
|
-
break;
|
428
|
-
|
429
|
-
}
|
430
|
-
|
431
|
-
}
|
432
|
-
|
433
|
-
});
|
447
|
+
```
|
448
|
+
|
449
|
+
```html
|
450
|
+
|
451
|
+
<!-- gallery -->
|
452
|
+
|
453
|
+
<div class="img-fit-01">
|
454
|
+
|
455
|
+
<div class="aspect-box spinner">
|
456
|
+
|
457
|
+
<img alt class="lazyload modal-imgs" src="data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==" style="width: 100%; height: 100%;" data-group="gallery-01" data-src="img/photo/04.png" data-caption="画像の詳細を書けます 01-02">
|
458
|
+
|
459
|
+
</div>
|
460
|
+
|
461
|
+
<aside>モーダルサンプル 02 / data-group でグループ化</aside>
|
462
|
+
|
463
|
+
</div>
|
464
|
+
|
465
|
+
|
466
|
+
|
467
|
+
<!-- image modal -->
|
468
|
+
|
469
|
+
<div class="modal-wrapper spinner">
|
470
|
+
|
471
|
+
<div class="modal-img">
|
472
|
+
|
473
|
+
<div class="mid"><img alt src="data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw=="></div>
|
474
|
+
|
475
|
+
<div class="mp-prev"></div>
|
476
|
+
|
477
|
+
<div class="mp-next"></div>
|
478
|
+
|
479
|
+
<div class="mp-close"></div>
|
480
|
+
|
481
|
+
<aside class="modal-aside">xxx</aside>
|
482
|
+
|
483
|
+
</div>
|
484
|
+
|
485
|
+
</div>
|
486
|
+
|
487
|
+
```
|
488
|
+
|
489
|
+
```css
|
490
|
+
|
491
|
+
.modal-wrapper {
|
492
|
+
|
493
|
+
opacity: 0;
|
434
494
|
|
435
495
|
}
|
436
496
|
|
437
497
|
|
438
498
|
|
499
|
+
.modal-wrapper.show {
|
500
|
+
|
501
|
+
opacity: 1;
|
502
|
+
|
503
|
+
}
|
504
|
+
|
505
|
+
|
506
|
+
|
507
|
+
.modal-img img {
|
508
|
+
|
509
|
+
opacity: 0;
|
510
|
+
|
511
|
+
}
|
512
|
+
|
513
|
+
|
514
|
+
|
515
|
+
.modal-img img.show {
|
516
|
+
|
517
|
+
opacity: 1;
|
518
|
+
|
519
|
+
}
|
520
|
+
|
439
521
|
```
|
440
522
|
|
441
|
-
```html
|
442
|
-
|
443
|
-
<!-- gallery -->
|
444
|
-
|
445
|
-
<div class="img-fit-01">
|
446
|
-
|
447
|
-
<div class="aspect-box spinner">
|
448
|
-
|
449
|
-
<img alt class="lazyload modal-imgs" src="data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==" style="width: 100%; height: 100%;" data-group="gallery-01" data-src="img/photo/04.png" data-caption="画像の詳細を書けます 01-02">
|
450
|
-
|
451
|
-
</div>
|
452
|
-
|
453
|
-
<aside>モーダルサンプル 02 / data-group でグループ化</aside>
|
454
|
-
|
455
|
-
</div>
|
456
|
-
|
457
|
-
|
458
|
-
|
459
|
-
<!-- image modal -->
|
460
|
-
|
461
|
-
<div class="modal-wrapper spinner">
|
462
|
-
|
463
|
-
<div class="modal-img">
|
464
|
-
|
465
|
-
<div class="mid"><img alt src="data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw=="></div>
|
466
|
-
|
467
|
-
<div class="mp-prev"></div>
|
468
|
-
|
469
|
-
<div class="mp-next"></div>
|
470
|
-
|
471
|
-
<div class="mp-close"></div>
|
472
|
-
|
473
|
-
<aside class="modal-aside">xxx</aside>
|
474
|
-
|
475
|
-
</div>
|
476
|
-
|
477
|
-
</div>
|
478
|
-
|
479
|
-
```
|
480
|
-
|
481
|
-
```css
|
482
|
-
|
483
|
-
.modal-wrapper {
|
484
|
-
|
485
|
-
opacity: 0;
|
486
|
-
|
487
|
-
}
|
488
|
-
|
489
|
-
|
490
|
-
|
491
|
-
.modal-wrapper.show {
|
492
|
-
|
493
|
-
opacity: 1;
|
494
|
-
|
495
|
-
}
|
496
|
-
|
497
|
-
|
498
|
-
|
499
|
-
.modal-img img {
|
500
|
-
|
501
|
-
opacity: 0;
|
502
|
-
|
503
|
-
}
|
504
|
-
|
505
|
-
|
506
|
-
|
507
|
-
.modal-img img.show {
|
508
|
-
|
509
|
-
opacity: 1;
|
510
|
-
|
511
|
-
}
|
512
|
-
|
513
|
-
```
|
514
|
-
|
515
523
|
|
516
524
|
|
517
525
|
### 試したこと
|