2016-04-14 4 views
0

私は作業していた単純な音楽トグルボタンをほとんど終了しました。トップページのスクロールボタンが私のウェブサイト(like the one which you can see here when scrolling down) )。 このJavaScriptコードを既存のコードに適用する際に役立つことが必要です

は、私は次のようになります一番上のボタンへスクロールからjavascriptを得ることができた:

var start = { 
    setting: { 
    startline: 100, 
    scrollto: 0, 
    scrollduration: 1e3, 
    fadeduration: [500, 100] 
    }, 
    controlHTML: '<img src=".../noaudio.png"/>', 
    }, 
    state: { 
    isvisible: !1, 
    shouldvisible: !1 
    }, 
    scrollup: function() { 
    this.cssfixedsupport || this.$control.css({ 
    opacity: 0 
    }); 
    var t = isNaN(this.setting.scrollto) ? this.setting.scrollto : parseInt(this.setting.scrollto); 
    t = "string" == typeof t && 1 == jQuery("#" + t).length ? jQuery("#" + t).offset().top : 0, this.$body.animate({ 
     scrollTop: t 
    }, this.setting.scrollduration) 
    }, 
    keepfixed: function() { 
    var t = jQuery(window), 
     o = t.scrollLeft() + t.width() - this.$control.width() - this.controlattrs.offsetx, 
     s = t.scrollTop() + t.height() - this.$control.height() - this.controlattrs.offsety; 
    this.$control.css({ 
     left: o + "px", 
     top: s + "px" 
    }) 
    }, 
    togglecontrol: function() { 
    var t = jQuery(window).scrollTop(); 
    this.cssfixedsupport || this.keepfixed(), this.state.shouldvisible = t >= this.setting.startline ? !0 : !1, this.state.shouldvisible && !this.state.isvisible ? (this.$control.stop().animate({ 
     opacity: 1 
    }, this.setting.fadeduration[0]), this.state.isvisible = !0) : 0 == this.state.shouldvisible && this.state.isvisible && (this.$control.stop().animate({ 
     opacity: 0 
    }, this.setting.fadeduration[1]), this.state.isvisible = !1) 
    }, 
    init: function() { 
    jQuery(document).ready(function(t) { 

私が追加された新しいボタンのために働くためにそれを変更することで、外出先に持っていたのが、今のところ何の運がなかったです。 [これまで私が行ってきたことは何ですか] [2]

私のウェブサイトのように新しいボタンをフェードインさせるにはどうすればよいですか?上にリンクされたコードでそれを行う方法はありますか?

おかげでまた

、すべてのエラーのために申し訳ありません。私はまだコードを吸う。

+0

「init」の残りの部分はどこですか? –

答えて

0

https://jsfiddle.net/71uncr2g/8/

これを試してみてください。私は今のようなことに取り組んでいました。これはjQueryのコードです:

var amountScrolled = 300; 

$(window).scroll(function() { 
    if ($(window).scrollTop() > amountScrolled) { 
     $('.fadebutton').fadeIn('slow'); 
    } else { 
     $('.fadebutton').fadeOut('slow'); 
    } 
});