function assert(value, desc){ var results = document.getElementById("results"); if(!results){ results = document.createElement("ul"); document.getElementsByTagName("body")[0].appendChild(results); results.setAttribute("id", "results"); } var li = document.createElement("li"); li.className = value ? "pass" : "fail"; li.appendChild(document.createTextNode(desc)); results.appendChild(li); } $(function(){ $('.menu_item').bind({ 'touchstart': function(e) { $(this).removeClass("notouchstyle").addClass("touchstyle"); }, 'touchend': function(e) { $(this).removeClass("touchstyle").addClass("notouchstyle"); }, 'touchmove': function(e) { $(this).removeClass("touchstyle").addClass("notouchstyle"); } }); }); $(function(){ $('.no_flick_item').bind({ 'touchstart': function(e) { $(this).removeClass("notouchstyle").addClass("touchstyle"); }, 'touchend': function(e) { $(this).removeClass("touchstyle").addClass("notouchstyle"); }, 'touchmove': function(e) { $(this).removeClass("touchstyle").addClass("notouchstyle"); } }); }); $(function(){ flickMenuDo(); }); //$(window).on('resize',function(){ // if(window.innerWidth < 500){ //assert(true, window.innerWidth + ":SmallDevice"); // applySmallDevice(); // }else{ //assert(true, window.innerWidth + ":BigDevice"); // applyBigDevice(); // } //}); function applySmallDevice(){ var no_flick_area = document.getElementsByClassName('no_flick_area'); for(var i=0; i$(this).width()?w:$(this).width(); h = h>$(this).height()?h:$(this).height(); }); $viewport.css({"overflow":"hidden"}); //$wraper.css({"width":w*$items.length+20*$items.length}); //distance:フリック時の移動距離と移動可能スパン var flipsnap = Flipsnap('.containerIn', {distance:70, transitionDuration: 250, maxPoint:2}); //controller var $next = $('.next').click(function() {flipsnap.toNext();}); var $prev = $('.prev').click(function() {flipsnap.toPrev();}); var arrowDisabledClass = 'off'; //navigation var moveendCallback = function(){ //navigation if(flipsnap.hasNext()){ $next.removeClass(arrowDisabledClass); }else{ $next.addClass(arrowDisabledClass); } if(flipsnap.hasPrev()){ $prev.removeClass(arrowDisabledClass); }else{ $prev.addClass(arrowDisabledClass); } //丸印の装飾 var first_circle = document.getElementById("first_circle"); var second_circle = document.getElementById("second_circle"); var third_circle = document.getElementById("third_circle"); if(flipsnap.hasNext() && !(flipsnap.hasPrev())){ first_circle.setAttribute("style", "background-color:#008ee8"); second_circle.setAttribute("style", "background-color:#bee9fe"); third_circle.setAttribute("style", "background-color:#bee9fe"); }else if(!(flipsnap.hasNext())){ first_circle.setAttribute("style", "background-color:#bee9fe"); second_circle.setAttribute("style", "background-color:#bee9fe"); third_circle.setAttribute("style", "background-color:#008ee8"); }else{ first_circle.setAttribute("style", "background-color:#bee9fe"); second_circle.setAttribute("style", "background-color:#008ee8"); third_circle.setAttribute("style", "background-color:#bee9fe"); } } flipsnap.element.addEventListener('fsmoveend', moveendCallback, false); moveendCallback(); //ターゲットとするアイコンの設定 //左端に設定したい場合は、htmlにdefault_icon_0を指定 //真ん中に設定したい場合は、htmlにdefault_icon_1を指定 //右端に設定したい場合は、htmlにdefault_icon_2を指定 if(document.getElementById("default_icon_1")){ flipsnap.moveToPoint(1); }else if(document.getElementById("default_icon_2")){ flipsnap.moveToPoint(2); }else if(document.getElementById("default_icon_3")){ flipsnap.moveToPoint(3); } //リフレッシュ //$(window).on('resize',function(){ // flipsnap.refresh(); //});   $(window).on('resize',function(){ var orientation = window.orientation; if(orientation == 0 && window.innerWidth < 300){ applySmallDevice(); flipsnap.refresh(); }else{ applyBigDevice(); } }); }); }); }