无法执行' scrollTo' on' Window':需要2个参数,但只有0个参数

时间:2015-12-28 14:57:38

标签: javascript meteor

我觉得我非常接近在我的应用程序中使用此插件。每当我按下其中一个导航栏元素时,就会发生错误。有关为何发生此错误的任何想法?

错误

无法执行' scrollTo' on' Window':需要2个参数,但只有0个参数。

降价

<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
        <ul class="nav navbar-nav navbar-right">
          <li class="hidden">
            <a href="./#top"></a>
          </li>

          <!--
                  <li>
                      <a class="page-scroll" href="#missions">Why</a>
                  </li> -->


          <li> <a class="page-scroll" id="missions" href="#missions">How</a> </li>

          <li>
            <a class="page-scroll" id="p2s" href="#p2s">What</a>
          </li>

          <li>
            <a class="page-scroll" id="footer" href="#footer">Sign-up</a>
          </li>
        </ul>

      </div>

JS逻辑

Meteor.startup(function() {


  var controller = new ScrollMagic.Controller();

  controller.scrollTo(function(target) {
    TweenMax.to(window, 0.5, {
      scrollTo: {
        y: target, 
        autoKill: true
      },
      ease: Cubic.easeInOut
    });


  console.log("in here");

  });


  $(document).on("click", "a[href^=#]", function(e) {
  var id = $(this).attr("href");

  if($(id).length > 0) {
    e.preventDefault();

    // trigger scroll
    controller.scrollTo(id);

    // If supported by the browser we can also update the URL
    if (window.history && window.history.pushState) {
      history.pushState("", document.title, id);
    }
  }

});

0 个答案:

没有答案