// JavaScript Document $(function() { var topBtn = $('.pageTop'); topBtn.hide(); //スクロールが150に達したらボタン表示 $(window).scroll(function () { if ($(this).scrollTop() > 150) { topBtn.fadeIn(); } else { topBtn.fadeOut(); } // フッター固定する // iwasaki // ドキュメントの高さ scrollHeight = $(document).height(); // ウィンドウの高さ+スクロールした高さ→ 現在のトップからの位置 scrollPosition = $(window).height() + $(window).scrollTop(); // フッターの高さ(marginを含めるため、outerHeight(true)を使用) footHeight = $(".siteFooter").outerHeight(true); // コピーライトの高さ(borderを含めるため、outerHeight(true)を使用) //copyHeight = $("#copyright").outerHeight(true); if ( scrollHeight - scrollPosition <= footHeight + 0 ) { //if ( scrollHeight - scrollPosition <= footHeight + copyHeight - 90 ) { // 現在の下から位置が、フッターの高さの位置にはいったら // "#page-top"のpositionをabsoluteに変更し、フッター++コピーの高さの位置にする topBtn.css({ //"position":"fixed", //"bottom": "0px" "position":"absolute", "bottom": footHeight }); } else { // それ以外の場合は元のcssスタイルを指定 topBtn.css({ "position":"fixed", "bottom": "0px" }); } }); //スクロールしてトップ topBtn.click(function () { $('body,html').animate({ scrollTop: 0 }, 500); return false; }); // 画面サイズ変更イベント $(window).resize(function () { // ドキュメントの高さ scrollHeight = $(document).height(); // ウィンドウの高さ+スクロールした高さ→ 現在のトップからの位置 scrollPosition = $(window).height() + $(window).scrollTop(); // フッターの高さ(marginを含めるため、outerHeight(true)を使用) footHeight = $(".siteFooter").outerHeight(true); // コピーライトの高さ(borderを含めるため、outerHeight(true)を使用) //copyHeight = $("#copyright").outerHeight(true); if ( scrollHeight - scrollPosition <= footHeight + 0 ) { //if ( scrollHeight - scrollPosition <= footHeight + copyHeight - 90 ) { // 現在の下から位置が、フッターの高さの位置にはいったら // "#page-top"のpositionをabsoluteに変更し、フッター+の高さの位置にする topBtn.css({ //""position":"fixed", //"bottom": "0px" "position":"absolute", "bottom": footHeight }); } else { // それ以外の場合は元のcssスタイルを指定 topBtn.css({ "position":"fixed", "bottom": "0px" }); } }); });