在smoothstate链接上停止步伐

时间:2017-07-12 11:28:42

标签: javascript jquery smoothstate.js pace.js

我试图在用户点击Smoothstate链接时停止加载pace.js。

我认为使用忽略设置在事件中使用smoothscroll调用Pace.stop,但仍会触发事件。

 $('.chronology-nav a').click ->
    Pace.stop

onStart:
      duration: 2000
      render: ($container) ->
        $container.addClass 'is-exiting'
        $('body').removeClass('done')
        Pace.stop

行。所以我找到了一个解决方案,它有点hacky,但对于任何挣扎这个的人。我在onStart方法上为smoothstate添加了一个类,并在css中将步调进度div显示为:none

Coffeescript代码片段

onStart:
      duration: 2000
      render: ($container) ->
        # add the tag that hides pace
        $('body').addClass('chronologyStart')
        $container.addClass 'is-exiting'
        Pace.stop
    onProgress:
      duration: 0
      render: ($container) ->
        Pace.stop
        $container.hide()
        return
    onReady:
      duration: 0
      render: ($container, $newContent) ->
        Pace.stop
        $container.show()
        smoothState.restartCSSAnimations()
        $('body').removeClass('chronologyStart')
        $container.html $newContent
        $container.removeClass 'is-exiting'
        return

0 个答案:

没有答案
相关问题