質問編集履歴

2

2020/12/29 06:04

投稿

HHH-
HHH-

スコア28

test CHANGED
File without changes
test CHANGED
@@ -49,317 +49,3 @@
49
49
  どうすればいいのですが?
50
50
 
51
51
  また私みたいなケースはJSアンカータグで解決できるのでしょうか…
52
-
53
-
54
-
55
-
56
-
57
- **追記**
58
-
59
- ```
60
-
61
-
62
-
63
-
64
-
65
- <ul class="nabox">
66
-
67
-
68
-
69
- <div style="float: left;" class="ui-thumbnail" tabindex="-1" data-key="1">
70
-
71
- <li style="display: inline-block;">
72
-
73
-
74
-
75
- <input type="button" class="nab"
76
-
77
- value="1"
78
-
79
- id="button1"
80
-
81
- onclick="disabled = true;
82
-
83
- getElementById('button2').disabled = false;
84
-
85
- getElementById('button3').disabled = false;
86
-
87
- getElementById('button4').disabled = false;
88
-
89
- getElementById('button5').disabled = false;">
90
-
91
-
92
-
93
- </li>
94
-
95
- </div>
96
-
97
-
98
-
99
- <div style="float: left;" class="ui-thumbnail" tabindex="-1" data-key="0">
100
-
101
- <li style="display: inline-block;">
102
-
103
-
104
-
105
- <input type="button" class="nab"
106
-
107
- value="2"
108
-
109
- id="button2" disabled
110
-
111
- onclick="disabled = true;
112
-
113
- getElementById('button1').disabled = false;
114
-
115
- getElementById('button3').disabled = false;
116
-
117
- getElementById('button4').disabled = false;
118
-
119
- getElementById('button5').disabled = false;">
120
-
121
-
122
-
123
- </li>
124
-
125
- </div>
126
-
127
-
128
-
129
- <div style="float: left;" class="ui-thumbnail" tabindex="-1" data-key="2">
130
-
131
- <li style="display: inline-block;">
132
-
133
-
134
-
135
- <input type="button" class="nab"
136
-
137
- value="3"
138
-
139
- id="button3"
140
-
141
- onclick="disabled = true;
142
-
143
- getElementById('button1').disabled = false;
144
-
145
- getElementById('button2').disabled = false;
146
-
147
- getElementById('button4').disabled = false;
148
-
149
- getElementById('button5').disabled = false;">
150
-
151
-
152
-
153
- </li>
154
-
155
- </div>
156
-
157
-
158
-
159
- <div style="float: left;" class="ui-thumbnail" tabindex="-1" data-key="3">
160
-
161
- <li style="display: inline-block;">
162
-
163
- <a id="ssd"></a>
164
-
165
- <input type="button" class="nab"
166
-
167
- value="4"
168
-
169
- id="button4"
170
-
171
- onclick="disabled = true;
172
-
173
- getElementById('button1').disabled = false;
174
-
175
- getElementById('button2').disabled = false;
176
-
177
- getElementById('button3').disabled = false;
178
-
179
- getElementById('button5').disabled = false;">
180
-
181
-
182
-
183
- </li>
184
-
185
- </div>
186
-
187
-
188
-
189
-
190
-
191
- <div style="float: left;" class="ui-thumbnail" tabindex="-1" data-key="4">
192
-
193
- <li style="display: inline-block;">
194
-
195
-
196
-
197
- <input type="button" class="nab"
198
-
199
- value="5"
200
-
201
- id="button5"
202
-
203
- onclick="disabled = true;
204
-
205
- getElementById('button1').disabled = false;
206
-
207
- getElementById('button2').disabled = false;
208
-
209
- getElementById('button3').disabled = false;
210
-
211
- getElementById('button4').disabled = false;">
212
-
213
-
214
-
215
- </li>
216
-
217
- </div>
218
-
219
-
220
-
221
-
222
-
223
-
224
-
225
- </ul>
226
-
227
-
228
-
229
- <script id="rendered-js">
230
-
231
- console.clear();
232
-
233
-
234
-
235
- const elPrevButton = document.querySelector('#prev');
236
-
237
- const elNextButton = document.querySelector('#next');
238
-
239
- const flipping = new Flipping();
240
-
241
-
242
-
243
- const elImages = Array.from(document.querySelectorAll('.ui-big-image'));
244
-
245
- const elThumbnails = Array.from(document.querySelectorAll('.ui-thumbnail'));
246
-
247
-
248
-
249
- let state = {
250
-
251
- photo: 0 };
252
-
253
-
254
-
255
-
256
-
257
- function send(event) {
258
-
259
- // read cuticle positions
260
-
261
- flipping.read();
262
-
263
-
264
-
265
- const elActives = document.querySelectorAll('[data-active]');
266
-
267
-
268
-
269
- Array.from(elActives).
270
-
271
- forEach(el => el.removeAttribute('data-active'));
272
-
273
-
274
-
275
- switch (event) {
276
-
277
- case 'PREV':
278
-
279
- state.photo--;
280
-
281
- // Math.max(state.photo - 1, 0);
282
-
283
- break;
284
-
285
- case 'NEXT':
286
-
287
- state.photo++;
288
-
289
- // Math.min(state.photo + 1, elImages.length - 1);
290
-
291
- break;
292
-
293
- default:
294
-
295
- state.photo = +event;
296
-
297
- break;}
298
-
299
-
300
-
301
-
302
-
303
- var len = elImages.length;
304
-
305
- // Loop Around
306
-
307
- //state.photo = ( ( state.photo % len) + len ) % len;
308
-
309
- state.photo = Math.max(0, Math.min(state.photo, len - 1));
310
-
311
-
312
-
313
- Array.from(document.querySelectorAll(`[data-key="${state.photo}"]`)).
314
-
315
- forEach(el => {
316
-
317
- el.setAttribute('data-active', true);
318
-
319
- });
320
-
321
-
322
-
323
- // execute the FLIP animation
324
-
325
- flipping.flip();
326
-
327
- }
328
-
329
-
330
-
331
- elThumbnails.forEach(thumb => {
332
-
333
- thumb.addEventListener('click', () => {
334
-
335
- send(thumb.dataset.key);
336
-
337
- });
338
-
339
- });
340
-
341
-
342
-
343
- elPrevButton.addEventListener('click', () => {
344
-
345
- send('PREV');
346
-
347
- });
348
-
349
-
350
-
351
- elNextButton.addEventListener('click', () => {
352
-
353
- send('NEXT');
354
-
355
- });
356
-
357
-
358
-
359
- send(0);
360
-
361
- //# sourceURL=pen.js
362
-
363
- </script>
364
-
365
- ```

1

追記

2020/12/29 06:04

投稿

HHH-
HHH-

スコア28

test CHANGED
File without changes
test CHANGED
@@ -49,3 +49,317 @@
49
49
  どうすればいいのですが?
50
50
 
51
51
  また私みたいなケースはJSアンカータグで解決できるのでしょうか…
52
+
53
+
54
+
55
+
56
+
57
+ **追記**
58
+
59
+ ```
60
+
61
+
62
+
63
+
64
+
65
+ <ul class="nabox">
66
+
67
+
68
+
69
+ <div style="float: left;" class="ui-thumbnail" tabindex="-1" data-key="1">
70
+
71
+ <li style="display: inline-block;">
72
+
73
+
74
+
75
+ <input type="button" class="nab"
76
+
77
+ value="1"
78
+
79
+ id="button1"
80
+
81
+ onclick="disabled = true;
82
+
83
+ getElementById('button2').disabled = false;
84
+
85
+ getElementById('button3').disabled = false;
86
+
87
+ getElementById('button4').disabled = false;
88
+
89
+ getElementById('button5').disabled = false;">
90
+
91
+
92
+
93
+ </li>
94
+
95
+ </div>
96
+
97
+
98
+
99
+ <div style="float: left;" class="ui-thumbnail" tabindex="-1" data-key="0">
100
+
101
+ <li style="display: inline-block;">
102
+
103
+
104
+
105
+ <input type="button" class="nab"
106
+
107
+ value="2"
108
+
109
+ id="button2" disabled
110
+
111
+ onclick="disabled = true;
112
+
113
+ getElementById('button1').disabled = false;
114
+
115
+ getElementById('button3').disabled = false;
116
+
117
+ getElementById('button4').disabled = false;
118
+
119
+ getElementById('button5').disabled = false;">
120
+
121
+
122
+
123
+ </li>
124
+
125
+ </div>
126
+
127
+
128
+
129
+ <div style="float: left;" class="ui-thumbnail" tabindex="-1" data-key="2">
130
+
131
+ <li style="display: inline-block;">
132
+
133
+
134
+
135
+ <input type="button" class="nab"
136
+
137
+ value="3"
138
+
139
+ id="button3"
140
+
141
+ onclick="disabled = true;
142
+
143
+ getElementById('button1').disabled = false;
144
+
145
+ getElementById('button2').disabled = false;
146
+
147
+ getElementById('button4').disabled = false;
148
+
149
+ getElementById('button5').disabled = false;">
150
+
151
+
152
+
153
+ </li>
154
+
155
+ </div>
156
+
157
+
158
+
159
+ <div style="float: left;" class="ui-thumbnail" tabindex="-1" data-key="3">
160
+
161
+ <li style="display: inline-block;">
162
+
163
+ <a id="ssd"></a>
164
+
165
+ <input type="button" class="nab"
166
+
167
+ value="4"
168
+
169
+ id="button4"
170
+
171
+ onclick="disabled = true;
172
+
173
+ getElementById('button1').disabled = false;
174
+
175
+ getElementById('button2').disabled = false;
176
+
177
+ getElementById('button3').disabled = false;
178
+
179
+ getElementById('button5').disabled = false;">
180
+
181
+
182
+
183
+ </li>
184
+
185
+ </div>
186
+
187
+
188
+
189
+
190
+
191
+ <div style="float: left;" class="ui-thumbnail" tabindex="-1" data-key="4">
192
+
193
+ <li style="display: inline-block;">
194
+
195
+
196
+
197
+ <input type="button" class="nab"
198
+
199
+ value="5"
200
+
201
+ id="button5"
202
+
203
+ onclick="disabled = true;
204
+
205
+ getElementById('button1').disabled = false;
206
+
207
+ getElementById('button2').disabled = false;
208
+
209
+ getElementById('button3').disabled = false;
210
+
211
+ getElementById('button4').disabled = false;">
212
+
213
+
214
+
215
+ </li>
216
+
217
+ </div>
218
+
219
+
220
+
221
+
222
+
223
+
224
+
225
+ </ul>
226
+
227
+
228
+
229
+ <script id="rendered-js">
230
+
231
+ console.clear();
232
+
233
+
234
+
235
+ const elPrevButton = document.querySelector('#prev');
236
+
237
+ const elNextButton = document.querySelector('#next');
238
+
239
+ const flipping = new Flipping();
240
+
241
+
242
+
243
+ const elImages = Array.from(document.querySelectorAll('.ui-big-image'));
244
+
245
+ const elThumbnails = Array.from(document.querySelectorAll('.ui-thumbnail'));
246
+
247
+
248
+
249
+ let state = {
250
+
251
+ photo: 0 };
252
+
253
+
254
+
255
+
256
+
257
+ function send(event) {
258
+
259
+ // read cuticle positions
260
+
261
+ flipping.read();
262
+
263
+
264
+
265
+ const elActives = document.querySelectorAll('[data-active]');
266
+
267
+
268
+
269
+ Array.from(elActives).
270
+
271
+ forEach(el => el.removeAttribute('data-active'));
272
+
273
+
274
+
275
+ switch (event) {
276
+
277
+ case 'PREV':
278
+
279
+ state.photo--;
280
+
281
+ // Math.max(state.photo - 1, 0);
282
+
283
+ break;
284
+
285
+ case 'NEXT':
286
+
287
+ state.photo++;
288
+
289
+ // Math.min(state.photo + 1, elImages.length - 1);
290
+
291
+ break;
292
+
293
+ default:
294
+
295
+ state.photo = +event;
296
+
297
+ break;}
298
+
299
+
300
+
301
+
302
+
303
+ var len = elImages.length;
304
+
305
+ // Loop Around
306
+
307
+ //state.photo = ( ( state.photo % len) + len ) % len;
308
+
309
+ state.photo = Math.max(0, Math.min(state.photo, len - 1));
310
+
311
+
312
+
313
+ Array.from(document.querySelectorAll(`[data-key="${state.photo}"]`)).
314
+
315
+ forEach(el => {
316
+
317
+ el.setAttribute('data-active', true);
318
+
319
+ });
320
+
321
+
322
+
323
+ // execute the FLIP animation
324
+
325
+ flipping.flip();
326
+
327
+ }
328
+
329
+
330
+
331
+ elThumbnails.forEach(thumb => {
332
+
333
+ thumb.addEventListener('click', () => {
334
+
335
+ send(thumb.dataset.key);
336
+
337
+ });
338
+
339
+ });
340
+
341
+
342
+
343
+ elPrevButton.addEventListener('click', () => {
344
+
345
+ send('PREV');
346
+
347
+ });
348
+
349
+
350
+
351
+ elNextButton.addEventListener('click', () => {
352
+
353
+ send('NEXT');
354
+
355
+ });
356
+
357
+
358
+
359
+ send(0);
360
+
361
+ //# sourceURL=pen.js
362
+
363
+ </script>
364
+
365
+ ```