$(function(){ $('.js-hoverImg').each(function(){ var src_off = $(this).find('img').attr('src'); var src_on = src_off.replace('_off','_on'); $('').attr('src',src_on); $(this).hover(function(){ $(this).find('img').attr('src',src_on); },function(){ $(this).find('img').attr('src',src_off); }); }); }); $(function(){ var $setElem = $('.js-switchImg'), pcName = '_pc', spName = '_sp', replaceWidth = 769; $setElem.each(function(){ var $this = $(this); function imgSize(){ var windowWidth = parseInt($(window).width()); if(windowWidth >= replaceWidth) { $this.attr('src',$this.attr('src').replace(spName,pcName)).css({visibility:'visible'}); } else if(windowWidth < replaceWidth) { $this.attr('src',$this.attr('src').replace(pcName,spName)).css({visibility:'visible'}); } } $(window).resize(function(){imgSize();}); imgSize(); }); }); /* ---------------------------------------------------------------------------- スクロールで画面表示 ---------------------------------------------------------------------------- */ $(function(){ $('.js-fadeIn').bind('inview', function(event, isInView, visiblePartX, visiblePartY) { $(this).animate({opacity:1},1000); }); }); $(function(){ $('.js-fadeIn01').bind('inview', function(event, isInView, visiblePartX, visiblePartY) { $(this).animate({opacity:1},2000); }); }); $(function(){ $('.js-fadeIn02').bind('inview', function(event, isInView, visiblePartX, visiblePartY) { $(this).animate({opacity:1},3000); }); }); $(function(){ $('.js-fadeIn03').bind('inview', function(event, isInView, visiblePartX, visiblePartY) { $(this).animate({opacity:1},4000); }); }); $(function(){ $('.js-fadeIn04').bind('inview', function(event, isInView, visiblePartX, visiblePartY) { $(this).animate({opacity:1},5000); }); }); $(function(){ $('.js-fadeIn05').bind('inview', function(event, isInView, visiblePartX, visiblePartY) { $(this).animate({opacity:1},6000); }); }); $(function(){ $('.js-fadeIn06').bind('inview', function(event, isInView, visiblePartX, visiblePartY) { $(this).animate({opacity:1},7000); }); }); /** * author Christopher Blum * - based on the idea of Remy Sharp, http://remysharp.com/2009/01/26/element-in-view-event-plugin/ * - forked from http://github.com/zuk/jquery.inview/ */ (function (factory) { if (typeof define == 'function' && define.amd) { // AMD define(['jquery'], factory); } else if (typeof exports === 'object') { // Node, CommonJS module.exports = factory(require('jquery')); } else { // Browser globals factory(jQuery); } }(function ($) { var inviewObjects = [], viewportSize, viewportOffset, d = document, w = window, documentElement = d.documentElement, timer; $.event.special.inview = { add: function(data) { inviewObjects.push({ data: data, $element: $(this), element: this }); // Use setInterval in order to also make sure this captures elements within // "overflow:scroll" elements or elements that appeared in the dom tree due to // dom manipulation and reflow // old: $(window).scroll(checkInView); // // By the way, iOS (iPad, iPhone, ...) seems to not execute, or at least delays // intervals while the user scrolls. Therefore the inview event might fire a bit late there // // Don't waste cycles with an interval until we get at least one element that // has bound to the inview event. if (!timer && inviewObjects.length) { timer = setInterval(checkInView, 250); } }, remove: function(data) { for (var i=0; i viewportOffset.top && elementOffset.top < viewportOffset.top + viewportSize.height && elementOffset.left + elementSize.width > viewportOffset.left && elementOffset.left < viewportOffset.left + viewportSize.width) { if (!inView) { $element.data('inview', true).trigger('inview', [true]); } } else if (inView) { $element.data('inview', false).trigger('inview', [false]); } } } $(w).bind("scroll resize scrollstop", function() { viewportSize = viewportOffset = null; }); // IE < 9 scrolls to focused elements without firing the "scroll" event if (!documentElement.addEventListener && documentElement.attachEvent) { documentElement.attachEvent("onfocusin", function() { viewportOffset = null; }); } })); $(function(){ var fix = $(".con01"); var fixTop = fix.offset().top; $(window).scroll(function () { if($(window).scrollTop() >= fixTop) { fix.addClass("fixed"); } else { fix.removeClass("fixed"); } }); }); $(function(){ var fix = $(".con02"); var fixTop = fix.offset().top; $(window).scroll(function () { if($(window).scrollTop() >= fixTop) { fix.addClass("fixed"); } else { fix.removeClass("fixed"); } }); }); $(function(){ var fix = $(".con03"); var fixTop = fix.offset().top; $(window).scroll(function () { if($(window).scrollTop() >= fixTop) { fix.addClass("fixed"); } else { fix.removeClass("fixed"); } }); }); $(function(){ var fix = $(".con04"); var fixTop = fix.offset().top; $(window).scroll(function () { if($(window).scrollTop() >= fixTop) { fix.addClass("fixed"); } else { fix.removeClass("fixed"); } }); });