サイドメニューのスタイル修正。画像が読み込まれてから追従を開始、リサイズした場合サイドメニュー表示位置の再計算を行う
Showing
1 changed file
with
41 additions
and
27 deletions
... | @@ -203,37 +203,51 @@ if ($this->params->get('logoFile')) { | ... | @@ -203,37 +203,51 @@ if ($this->params->get('logoFile')) { |
203 | <link rel="apple-touch-icon" href="/apple-touch-icon.png"> | 203 | <link rel="apple-touch-icon" href="/apple-touch-icon.png"> |
204 | 204 | ||
205 | <script> | 205 | <script> |
206 | jQuery(function($) { | 206 | window.onload = function() { |
207 | var obj = $("#aside"); | 207 | jQuery(function($) { |
208 | var offset = $(obj).offset(); | 208 | var obj = $("#aside"); |
209 | var topPadding = 135; | 209 | var sW = window.innerWidth; |
210 | var sW = window.innerWidth; | 210 | var sH = window.innerHeight; |
211 | var sH = window.innerHeight; | 211 | var cW = obj.width(); |
212 | var cW = obj.width(); | 212 | var cH = obj.height(); |
213 | var cH = obj.height(); | 213 | var cwrapH = $("#c_wrap").height(); |
214 | var cwrapH = $("#c_wrap").height(); | 214 | // 特定のページではスクロールしない |
215 | 215 | var excludedPages = [".record-page"]; | |
216 | if (cH) { | 216 | var excludedPagesSelector = excludedPages.join(', '); |
217 | if (sH > cH) { | 217 | var isExcluded = false; |
218 | $(window).scroll(function() { | 218 | if (document.querySelector(excludedPagesSelector)) { |
219 | if ($(window).scrollTop() > offset.top) { | 219 | isExcluded = true; |
220 | if ($(window).scrollTop() < cwrapH) { | 220 | } |
221 | var customHeight = $(".custom").height(); | ||
222 | var paddingTop = customHeight - 80; | ||
223 | |||
224 | if (cH) { | ||
225 | if (sH > cH) { | ||
226 | if (isExcluded) return false; | ||
227 | $(window).resize(function() { | ||
228 | customHeight = $(".custom").height(); | ||
229 | paddingTop = customHeight - 80; | ||
230 | }); | ||
231 | $(window).scroll(function() { | ||
232 | if ($(window).scrollTop() > customHeight) { | ||
233 | if ($(window).scrollTop() < cwrapH) { | ||
234 | $(obj).stop().animate({ | ||
235 | duration: 'fast', | ||
236 | marginTop: $(window).scrollTop() - paddingTop | ||
237 | }); | ||
238 | } else { | ||
239 | $(obj).stop().animate({}); | ||
240 | } | ||
241 | } else { | ||
221 | $(obj).stop().animate({ | 242 | $(obj).stop().animate({ |
222 | duration: 'fast', | 243 | marginTop: 0 |
223 | marginTop: $(window).scrollTop() - offset.top + topPadding | ||
224 | }); | 244 | }); |
225 | } else { | ||
226 | $(obj).stop().animate({}); | ||
227 | } | 245 | } |
228 | } else { | 246 | }); |
229 | $(obj).stop().animate({ | 247 | } |
230 | marginTop: 0 | ||
231 | }); | ||
232 | } | ||
233 | }); | ||
234 | } | 248 | } |
235 | } | 249 | }); |
236 | }); | 250 | }; |
237 | </script> | 251 | </script> |
238 | 252 | ||
239 | </head> | 253 | </head> | ... | ... |
-
Please register or sign in to post a comment