2017-08-28 24 views
1

私のワードプレスのウェブサイトにハンバーガーメニューがあります。応答性に関しては、すべてが機能していますが、IPadの肖像画です。問題は、 - ハンバーガーメニューをクリックすると、1秒間拡張されてからすぐに終了します。代わりに、開いたままにすべきです。私は、次のapp.jsのファイルを持っている:ハンバーガーメニューが開き、すぐに閉じる

!function ($) { 


/* COLLAPSE PUBLIC CLASS DEFINITION 
    * ================================ */ 

    var Collapse = function (element, options) { 
    this.$element = $(element) 
    this.options = $.extend({}, $.fn.collapse.defaults, options) 

    if (this.options.parent) { 
     this.$parent = $(this.options.parent) 
    } 

    this.options.toggle && this.toggle() 
    } 

    Collapse.prototype = { 

    constructor: Collapse 

    , dimension: function() { 
     var hasWidth = this.$element.hasClass('width') 
     return hasWidth ? 'width' : 'height' 
    } 

    , show: function() { 
     var dimension 
     , scroll 
     , actives 
     , hasData 

     if (this.transitioning || this.$element.hasClass('in')) return 

     dimension = this.dimension() 
     scroll = $.camelCase(['scroll', dimension].join('-')) 
     actives = this.$parent && this.$parent.find('> .accordion-group > .in') 

     if (actives && actives.length) { 
     hasData = actives.data('collapse') 
     if (hasData && hasData.transitioning) return 
     actives.collapse('hide') 
     hasData || actives.data('collapse', null) 
     } 

     this.$element[dimension](0) 
     this.transition('addClass', $.Event('show'), 'shown') 
     $.support.transition && this.$element[dimension](this.$element[0][scroll]) 
    } 

    , hide: function() { 
     var dimension 
     if (this.transitioning || !this.$element.hasClass('in')) return 
     dimension = this.dimension() 
     this.reset(this.$element[dimension]()) 
     this.transition('removeClass', $.Event('hide'), 'hidden') 
     this.$element[dimension](0) 
    } 

    , reset: function (size) { 
     var dimension = this.dimension() 

     this.$element 
     .removeClass('collapse') 
     [dimension](size || 'auto') 
     [0].offsetWidth 

     this.$element[size !== null ? 'addClass' : 'removeClass']('collapse') 

     return this 
    } 

    , transition: function (method, startEvent, completeEvent) { 
     var that = this 
     , complete = function() { 
      if (startEvent.type == 'show') that.reset() 
      that.transitioning = 0 
      that.$element.trigger(completeEvent) 
      } 

     this.$element.trigger(startEvent) 

     if (startEvent.isDefaultPrevented()) return 

     this.transitioning = 1 

     this.$element[method]('in') 

     $.support.transition && this.$element.hasClass('collapse') ? 
     this.$element.one($.support.transition.end, complete) : 
     complete() 
    } 

    , toggle: function() { 
     this[this.$element.hasClass('in') ? 'hide' : 'show']() 
    } 

    } 


/* COLLAPSE PLUGIN DEFINITION 
    * ========================== */ 

    var old = $.fn.collapse 

    $.fn.collapse = function (option) { 
    return this.each(function() { 
     var $this = $(this) 
     , data = $this.data('collapse') 
     , options = $.extend({}, $.fn.collapse.defaults, $this.data(), typeof option == 'object' && option) 
     if (!data) $this.data('collapse', (data = new Collapse(this, options))) 
     if (typeof option == 'string') data[option]() 
    }) 
    } 

    $.fn.collapse.defaults = { 
    toggle: true 
    } 

    $.fn.collapse.Constructor = Collapse 


/* COLLAPSE NO CONFLICT 
    * ==================== */ 

    $.fn.collapse.noConflict = function() { 
    $.fn.collapse = old 
    return this 
    } 


/* COLLAPSE DATA-API 
    * ================= */ 

    $(document).on('click.collapse.data-api', '[data-toggle=collapse]', function (e) { 
    var $this = $(this), href 
     , target = $this.attr('data-target') 
     || e.preventDefault() 
     || (href = $this.attr('href')) && href.replace(/.*(?=#[^\s]+$)/, '') //strip for ie7 
     , option = $(target).data('collapse') ? 'toggle' : $this.data() 
    $this[$(target).hasClass('in') ? 'addClass' : 'removeClass']('collapsed') 
    $(target).collapse(option) 
    }) 

}(window.jQuery); 


jQuery(document).ready(function ($) { 

    var lastId, 
     topMenu = $("#top-navigation"), 
     topMenuHeight = topMenu.outerHeight(), 
     // All list items 
     menuItems = topMenu.find("a"), 
     // Anchors corresponding to menu items 
     scrollItems = menuItems.map(function() { 
      var item = $($(this).attr("href")); 
      if (item.length) { 
       return item; 
      } 
     }); 


    // Bind to scroll 
    $(window).scroll(function() { 

     //Display or hide scroll to top button 
     if ($(this).scrollTop() > 300) { 
      $('.scrollup').fadeIn(); 
     } else { 
      $('.scrollup').fadeOut(); 
     } 

     if ($(this).scrollTop() > 330) { 
      $('.navbar').addClass('navbar-fixed-top animated fadeInDown'); 
     } else { 
      $('.navbar').removeClass('navbar-fixed-top animated fadeInDown'); 
     } 

     // Get container scroll position 
     var fromTop = $(this).scrollTop() + topMenuHeight + 10; 

     // Get id of current scroll item 
     var cur = scrollItems.map(function() { 
      if ($(this).offset().top < fromTop) 
       return this; 
     }); 

     // Get the id of the current element 
     cur = cur[cur.length - 1]; 
     var id = cur && cur.length ? cur[0].id : ""; 

     if (lastId !== id) { 
      lastId = id; 
      // Set/remove active class 
      menuItems 
       .parent().removeClass("active") 
       .end().filter("[href=#" + id + "]").parent().addClass("active"); 
     } 
    }); 

    /* 
    Function for scroliing to top 
    ************************************/ 
    $('.scrollup').click(function() { 
     $("html, body").animate({ 
      scrollTop: 0 
     }, 600); 
     return false; 
    }); 


    $(window).load(function() { 
     function filterPath(string) { 
      return string.replace(/^\//, '').replace(/(index|default).[a-zA-Z]{3,4}$/, '').replace(/\/$/, ''); 
     } 
     $('a[href*=#]').each(function() { 
      if (filterPath(location.pathname) == filterPath(this.pathname) && location.hostname == this.hostname && this.hash.replace(/#/, '')) { 
       var $targetId = $(this.hash), 
        $targetAnchor = $('[name=' + this.hash.slice(1) + ']'); 
       var $target = $targetId.length ? $targetId : $targetAnchor.length ? $targetAnchor : false; 

       if ($target) { 

        $(this).click(function() { 

         //Hack collapse top navigation after clicking 
         topMenu.parent().attr('style', 'height:0px').removeClass('in'); //Close navigation 
         $('.navbar .btn-navbar').addClass('collapsed'); 
         var targetOffset = $target.offset().top - 63; 
         $('html, body').animate({ 
          scrollTop: targetOffset 
         }, 800); 
         return false; 
        }); 



       } 
      } 
     }); 
    }); 
}); 

私もfolllowing CSSファイルがあります:私は、この作品を作るために必死だ

.animated{-webkit-animation-fill-mode:both;-moz-animation-fill-mode:both;-ms-animation-fill-mode:both;-o-animation-fill-mode:both;animation-fill-mode:both;-webkit-animation-duration:1s;-moz-animation-duration:1s;-ms-animation-duration:1s;-o-animation-duration:1s;animation-duration:1s;} 
.animated.hinge{-webkit-animation-duration:1s;-moz-animation-duration:1s;-ms-animation-duration:1s;-o-animation-duration:1s;animation-duration:1s;} 


@-webkit-keyframes fadeInDown { 
    0% { 
     opacity: 0; 
     -webkit-transform: translateY(-20px); 
    } 

    100% { 
     opacity: 1; 
     -webkit-transform: translateY(0); 
    } 
} 

@-moz-keyframes fadeInDown { 
    0% { 
     opacity: 0; 
     -moz-transform: translateY(-20px); 
    } 

    100% { 
     opacity: 1; 
     -moz-transform: translateY(0); 
    } 
} 

@-o-keyframes fadeInDown { 
    0% { 
     opacity: 0; 
     -o-transform: translateY(-20px); 
    } 

    100% { 
     opacity: 1; 
     -o-transform: translateY(0); 
    } 
} 

@keyframes fadeInDown { 
    0% { 
     opacity: 0; 
     transform: translateY(-20px); 
    } 

    100% { 
     opacity: 1; 
     transform: translateY(0); 
    } 
} 

.fadeInDown { 
    -webkit-animation-name: fadeInDown; 
    -moz-animation-name: fadeInDown; 
    -o-animation-name: fadeInDown; 
    animation-name: fadeInDown; 
    cursor: pointer; 

} 

を、私は考えているか、との私の経験からこれはあまりありません。どんな提案も高く評価されます。 Thanx

+1

共有できる作業バージョンがありますか?それはクリックハンドラと関係があるかもしれませんが、読んで(少なくとも私のために)それを判断するにはあまりにも多くのコードがあります。 – Thijs

答えて

2

何時間もの絶望の後、私はそれがあることに気付きました。 js他の.jsファイルと競合していました。その特定の.jsファイルがハンバーガーメニューにのみ接続されていたので、私がしたのは名前を変更したため、ページ全体には存在しませんでした。私はこれが誰かを助けることを望む。 .jsファイルが互いに競合していないか常に確認してください。

関連する問題