// 枠いっぱいにフォントサイズを自動調整 /*global jQuery */ /*! * FitText.js 1.2 * * Copyright 2011, Dave Rupert http://daverupert.com * Released under the WTFPL license * http://sam.zoy.org/wtfpl/ * * Date: Thu May 05 14:23:00 2011 -0600 */ (function( $ ){ $.fn.fitText = function( kompressor, options ) { // Setup options var compressor = kompressor || 1, settings = $.extend({ 'minFontSize' : Number.NEGATIVE_INFINITY, 'maxFontSize' : Number.POSITIVE_INFINITY }, options); return this.each(function(){ // Store the object var $this = $(this); // Resizer() resizes items based on the object width divided by the compressor * 10 var resizer = function () { $this.css('font-size', Math.max(Math.min($this.width() / (compressor*10), parseFloat(settings.maxFontSize)), parseFloat(settings.minFontSize))); }; // Call once to set. resizer(); // Call on resize. Opera debounces their resize by default. $(window).on('resize.fittext orientationchange.fittext', resizer); }); }; })( jQuery ); $(function(){ // フェードイン $('body').removeClass('fadeout'); $('a:not([href^="#"]):not([target])').on('click', function(e){ e.preventDefault(); // ナビゲートをキャンセル url = $(this).attr('href'); // 遷移先のURLを取得 if (url !== '') { $('body').addClass('fadeout'); // bodyに class="fadeout"を挿入 setTimeout(function(){ window.location = url; // 0.8秒後に取得したURLに遷移 }, 800); } return false; }); // 個別商品画面は商品情報までスクロール var file_name = window.location.href.split('/').pop().slice( 0, 4 ); if(file_name == 'item'){ var position = $("#main").offset().top; setTimeout(function(){ $('body,html').animate({scrollTop:position}, 1000, 'swing'); }, 800); } //スクロールが500に達したら背景を暗く $(window).scroll(function () { if ($(this).scrollTop() > 500) { $('.txt').css('z-index', 1); } else { $('.txt').css('z-index', 1000); } }); // 枠いっぱいにのフォントサイズにする対象 $("#title_1").fitText(); // スムーズスクロール // ----------------------- // #で始まるアンカーをクリックした場合に処理 $('a[href^=#]').click(function() { // スクロールの速度 var speed = 400; // ミリ秒 // アンカーの値取得 var href= $(this).attr("href"); // 移動先を取得 var target = $(href == "#" || href == "" ? 'html' : href); // 移動先を数値で取得 var position = target.offset().top; // スムーススクロール $('body,html').animate({scrollTop:position}, speed, 'swing'); return false; }); });