質問編集履歴
2
jsのソースコードを追加しました
test
CHANGED
File without changes
|
test
CHANGED
@@ -42,6 +42,88 @@
|
|
42
42
|
|
43
43
|
}
|
44
44
|
|
45
|
+
|
46
|
+
|
47
|
+
jsのソース main.js
|
48
|
+
|
49
|
+
|
50
|
+
|
51
|
+
var speed = 3;
|
52
|
+
|
53
|
+
|
54
|
+
|
55
|
+
var slideHeight;
|
56
|
+
|
57
|
+
|
58
|
+
|
59
|
+
function showParallax() {
|
60
|
+
|
61
|
+
var scrollTop = $(window).scrollTop();
|
62
|
+
|
63
|
+
|
64
|
+
|
65
|
+
$(".parallax-section-1").css({
|
66
|
+
|
67
|
+
"background-position": "center " + Math.round((0 - scrollTop) / speed) + "px",
|
68
|
+
|
69
|
+
});
|
70
|
+
|
71
|
+
$(".parallax-section-2").css({
|
72
|
+
|
73
|
+
"background-position": "center " + Math.round((slideHeight - scrollTop) / speed) + "px",
|
74
|
+
|
75
|
+
});
|
76
|
+
|
77
|
+
$(".parallax-section-3").css({
|
78
|
+
|
79
|
+
"background-position": "center " + Math.round((slideHeight * 2 - scrollTop) / speed) + "px",
|
80
|
+
|
81
|
+
});
|
82
|
+
|
83
|
+
$(".parallax-section-4").css({
|
84
|
+
|
85
|
+
"background-position": "center " + Math.round((slideHeight * 3 - scrollTop) / speed) + "px",
|
86
|
+
|
87
|
+
});
|
88
|
+
|
89
|
+
}
|
90
|
+
|
91
|
+
|
92
|
+
|
93
|
+
function initParallax() {
|
94
|
+
|
95
|
+
|
96
|
+
|
97
|
+
slideHeight = $(window).height();
|
98
|
+
|
99
|
+
showParallax();
|
100
|
+
|
101
|
+
}
|
102
|
+
|
103
|
+
|
104
|
+
|
105
|
+
$(document).ready(function() {
|
106
|
+
|
107
|
+
initParallax();
|
108
|
+
|
109
|
+
|
110
|
+
|
111
|
+
$(window).scroll(showParallax);
|
112
|
+
|
113
|
+
});
|
114
|
+
|
115
|
+
|
116
|
+
|
117
|
+
$(window).resize(function() {
|
118
|
+
|
119
|
+
|
120
|
+
|
121
|
+
initParallax();
|
122
|
+
|
123
|
+
});
|
124
|
+
|
125
|
+
|
126
|
+
|
45
127
|
```
|
46
128
|
|
47
129
|
|
1
test
CHANGED
File without changes
|
test
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
|
4
4
|
|
5
|
-
外部ライブラリーmobile-detect.jsを利用したい
|
5
|
+
外部ライブラリーmobile-detect.jsを利用してモバイルではparallaxを使用しないサイトを作成したいのですが、記載方法が分からず質問をさせて頂いています。
|
6
6
|
|
7
7
|
|
8
8
|
|
@@ -12,9 +12,7 @@
|
|
12
12
|
|
13
13
|
```
|
14
14
|
|
15
|
-
|
15
|
+
どう記述をしたらモバイルとpcでparallax効果をオンオフに分けることが出来るのか分かりません。
|
16
|
-
|
17
|
-
無知ですみません…。
|
18
16
|
|
19
17
|
```
|
20
18
|
|