質問編集履歴
1
コードの追加、問題箇所を調査しました。
test
CHANGED
File without changes
|
test
CHANGED
@@ -1,9 +1,285 @@
|
|
1
|
+
トップページはスマホナビが動くんでエスが下層ページだとスマホのナビが動きません。
|
2
|
+
|
3
|
+
調べたところ、下記javascriptが要因みたいんなのですが、どこが間違っていますでしょうか?
|
4
|
+
|
5
|
+
|
6
|
+
|
7
|
+
|
8
|
+
|
9
|
+
```javascript
|
10
|
+
|
11
|
+
jQuery(document).ready(function($){
|
12
|
+
|
13
|
+
var slidesWrapper = $('.cd-hero-slider');
|
14
|
+
|
15
|
+
|
16
|
+
|
17
|
+
//check if a .cd-hero-slider exists in the DOM
|
18
|
+
|
19
|
+
if ( slidesWrapper.length > 0 ) {
|
20
|
+
|
21
|
+
var primaryNav = $('.cd-primary-nav'),
|
22
|
+
|
23
|
+
sliderNav = $('.cd-slider-nav'),
|
24
|
+
|
25
|
+
navigationMarker = $('.cd-marker'),
|
26
|
+
|
27
|
+
slidesNumber = slidesWrapper.children('li').length,
|
28
|
+
|
29
|
+
visibleSlidePosition = 0,
|
30
|
+
|
31
|
+
autoPlayId,
|
32
|
+
|
33
|
+
autoPlayDelay = 5000;
|
34
|
+
|
35
|
+
|
36
|
+
|
37
|
+
//upload videos (if not on mobile devices)
|
38
|
+
|
39
|
+
uploadVideo(slidesWrapper);
|
40
|
+
|
41
|
+
|
42
|
+
|
43
|
+
//autoplay slider
|
44
|
+
|
45
|
+
setAutoplay(slidesWrapper, slidesNumber, autoPlayDelay);
|
46
|
+
|
47
|
+
|
48
|
+
|
49
|
+
//on mobile - open/close primary navigation clicking/tapping the menu icon
|
50
|
+
|
51
|
+
primaryNav.on('click', function(event){
|
52
|
+
|
53
|
+
if($(event.target).is('.cd-primary-nav')) $(this).children('ul').toggleClass('is-visible');
|
54
|
+
|
55
|
+
});
|
56
|
+
|
57
|
+
|
58
|
+
|
59
|
+
//change visible slide
|
60
|
+
|
61
|
+
sliderNav.on('click', 'li', function(event){
|
62
|
+
|
63
|
+
event.preventDefault();
|
64
|
+
|
65
|
+
var selectedItem = $(this);
|
66
|
+
|
67
|
+
if(!selectedItem.hasClass('selected')) {
|
68
|
+
|
69
|
+
// if it's not already selected
|
70
|
+
|
71
|
+
var selectedPosition = selectedItem.index(),
|
72
|
+
|
73
|
+
activePosition = slidesWrapper.find('li.selected').index();
|
74
|
+
|
75
|
+
|
76
|
+
|
77
|
+
if( activePosition < selectedPosition) {
|
78
|
+
|
79
|
+
nextSlide(slidesWrapper.find('.selected'), slidesWrapper, sliderNav, selectedPosition);
|
80
|
+
|
81
|
+
} else {
|
82
|
+
|
83
|
+
prevSlide(slidesWrapper.find('.selected'), slidesWrapper, sliderNav, selectedPosition);
|
84
|
+
|
85
|
+
}
|
86
|
+
|
87
|
+
|
88
|
+
|
89
|
+
//this is used for the autoplay
|
90
|
+
|
91
|
+
visibleSlidePosition = selectedPosition;
|
92
|
+
|
93
|
+
|
94
|
+
|
95
|
+
updateSliderNavigation(sliderNav, selectedPosition);
|
96
|
+
|
97
|
+
updateNavigationMarker(navigationMarker, selectedPosition+1);
|
98
|
+
|
99
|
+
//reset autoplay
|
100
|
+
|
101
|
+
setAutoplay(slidesWrapper, slidesNumber, autoPlayDelay);
|
102
|
+
|
103
|
+
}
|
104
|
+
|
105
|
+
});
|
106
|
+
|
107
|
+
}
|
108
|
+
|
109
|
+
|
110
|
+
|
111
|
+
function nextSlide(visibleSlide, container, pagination, n){
|
112
|
+
|
113
|
+
visibleSlide.removeClass('selected from-left from-right').addClass('is-moving').one('webkitTransitionEnd otransitionend oTransitionEnd msTransitionEnd transitionend', function(){
|
114
|
+
|
115
|
+
visibleSlide.removeClass('is-moving');
|
116
|
+
|
117
|
+
});
|
118
|
+
|
119
|
+
|
120
|
+
|
121
|
+
container.children('li').eq(n).addClass('selected from-right').prevAll().addClass('move-left');
|
122
|
+
|
123
|
+
checkVideo(visibleSlide, container, n);
|
124
|
+
|
125
|
+
}
|
126
|
+
|
127
|
+
|
128
|
+
|
129
|
+
function prevSlide(visibleSlide, container, pagination, n){
|
130
|
+
|
131
|
+
visibleSlide.removeClass('selected from-left from-right').addClass('is-moving').one('webkitTransitionEnd otransitionend oTransitionEnd msTransitionEnd transitionend', function(){
|
132
|
+
|
133
|
+
visibleSlide.removeClass('is-moving');
|
134
|
+
|
135
|
+
});
|
136
|
+
|
137
|
+
|
138
|
+
|
139
|
+
container.children('li').eq(n).addClass('selected from-left').removeClass('move-left').nextAll().removeClass('move-left');
|
140
|
+
|
141
|
+
checkVideo(visibleSlide, container, n);
|
142
|
+
|
143
|
+
}
|
144
|
+
|
145
|
+
|
146
|
+
|
147
|
+
function updateSliderNavigation(pagination, n) {
|
148
|
+
|
149
|
+
var navigationDot = pagination.find('.selected');
|
150
|
+
|
151
|
+
navigationDot.removeClass('selected');
|
152
|
+
|
153
|
+
pagination.find('li').eq(n).addClass('selected');
|
154
|
+
|
155
|
+
}
|
156
|
+
|
157
|
+
|
158
|
+
|
159
|
+
function setAutoplay(wrapper, length, delay) {
|
160
|
+
|
161
|
+
if(wrapper.hasClass('autoplay')) {
|
162
|
+
|
163
|
+
clearInterval(autoPlayId);
|
164
|
+
|
165
|
+
autoPlayId = window.setInterval(function(){autoplaySlider(length)}, delay);
|
166
|
+
|
167
|
+
}
|
168
|
+
|
169
|
+
}
|
170
|
+
|
171
|
+
|
172
|
+
|
173
|
+
function autoplaySlider(length) {
|
174
|
+
|
175
|
+
if( visibleSlidePosition < length - 1) {
|
176
|
+
|
177
|
+
nextSlide(slidesWrapper.find('.selected'), slidesWrapper, sliderNav, visibleSlidePosition + 1);
|
178
|
+
|
179
|
+
visibleSlidePosition +=1;
|
180
|
+
|
181
|
+
} else {
|
182
|
+
|
183
|
+
prevSlide(slidesWrapper.find('.selected'), slidesWrapper, sliderNav, 0);
|
184
|
+
|
185
|
+
visibleSlidePosition = 0;
|
186
|
+
|
187
|
+
}
|
188
|
+
|
189
|
+
updateNavigationMarker(navigationMarker, visibleSlidePosition+1);
|
190
|
+
|
191
|
+
updateSliderNavigation(sliderNav, visibleSlidePosition);
|
192
|
+
|
193
|
+
}
|
194
|
+
|
195
|
+
|
196
|
+
|
197
|
+
function uploadVideo(container) {
|
198
|
+
|
199
|
+
container.find('.cd-bg-video-wrapper').each(function(){
|
200
|
+
|
201
|
+
var videoWrapper = $(this);
|
202
|
+
|
203
|
+
if( videoWrapper.is(':visible') ) {
|
204
|
+
|
205
|
+
// if visible - we are not on a mobile device
|
206
|
+
|
207
|
+
var videoUrl = videoWrapper.data('video'),
|
208
|
+
|
209
|
+
video = $('<video loop><source src="'+videoUrl+'.mp4" type="video/mp4" /><source src="'+videoUrl+'.webm" type="video/webm" /></video>');
|
210
|
+
|
211
|
+
video.appendTo(videoWrapper);
|
212
|
+
|
213
|
+
// play video if first slide
|
214
|
+
|
215
|
+
if(videoWrapper.parent('.cd-bg-video.selected').length > 0) video.get(0).play();
|
216
|
+
|
217
|
+
}
|
218
|
+
|
219
|
+
});
|
220
|
+
|
221
|
+
}
|
222
|
+
|
223
|
+
|
224
|
+
|
225
|
+
function checkVideo(hiddenSlide, container, n) {
|
226
|
+
|
227
|
+
//check if a video outside the viewport is playing - if yes, pause it
|
228
|
+
|
229
|
+
var hiddenVideo = hiddenSlide.find('video');
|
230
|
+
|
231
|
+
if( hiddenVideo.length > 0 ) hiddenVideo.get(0).pause();
|
232
|
+
|
233
|
+
|
234
|
+
|
235
|
+
//check if the select slide contains a video element - if yes, play the video
|
236
|
+
|
237
|
+
var visibleVideo = container.children('li').eq(n).find('video');
|
238
|
+
|
239
|
+
if( visibleVideo.length > 0 ) visibleVideo.get(0).play();
|
240
|
+
|
241
|
+
}
|
242
|
+
|
243
|
+
|
244
|
+
|
245
|
+
function updateNavigationMarker(marker, n) {
|
246
|
+
|
247
|
+
marker.removeClassPrefix('item').addClass('item-'+n);
|
248
|
+
|
249
|
+
}
|
250
|
+
|
251
|
+
|
252
|
+
|
253
|
+
$.fn.removeClassPrefix = function(prefix) {
|
254
|
+
|
255
|
+
//remove all classes starting with 'prefix'
|
256
|
+
|
257
|
+
this.each(function(i, el) {
|
258
|
+
|
259
|
+
var classes = el.className.split(" ").filter(function(c) {
|
260
|
+
|
261
|
+
return c.lastIndexOf(prefix, 0) !== 0;
|
262
|
+
|
263
|
+
});
|
264
|
+
|
265
|
+
el.className = $.trim(classes.join(" "));
|
266
|
+
|
267
|
+
});
|
268
|
+
|
269
|
+
return this;
|
270
|
+
|
271
|
+
};
|
272
|
+
|
273
|
+
});
|
274
|
+
|
275
|
+
```
|
276
|
+
|
277
|
+
|
278
|
+
|
1
|
-
|
279
|
+
ページのURLです。
|
2
|
-
|
3
|
-
|
4
280
|
|
5
281
|
http://matumoto-motors.com/%E6%9D%BF%E9%87%91%E5%A1%97%E8%A3%85/
|
6
282
|
|
7
283
|
|
8
284
|
|
9
|
-
|
285
|
+
お手数をおかけいたしますが、何卒よろしくお願いいたします。
|