マウスホイールを使用してセクションをアニメーション化するためのアイデア - キーボードとスワイプの入力と終了。各セクションには異なるアニメーションがあります。 すべてがグローバル変数内のwrappです。ここではこれまでのところ大きなサンプル連結機能
var siteGlobal = (function(){
init();
var init = function(){
bindEvents();
}
// then i got my function to bind events
var bindEvents = function(){
$(document).on('mousewheel', mouseNav());
$(document).on('keyup', mouseNav());
}
// then i got my function here for capture the event
var mouseNav = function(){
// the code here for capturing direction or keyboard
// and then check next section
}
var nextSection = function(){
// Here we check if there is prev() or next() section
// if there is do the change on the section
}
var switchSection = function(nextsection){
// Get the current section and remove active class
// get the next section - add active class
// get the name of the function with data-name attribute
// trow the animation
var funcEnter = window['section'+ Name + 'Enter'];
}
// Let's pretend section is call Intro
var sectionIntroEnter = function(){
// animation code here
}
var sectionIntroExit = function(){
// animation code here
}
}();
はfuncEnter()と何を呼び出すまではとても良いですが起こる 私はまだ私は私は、実際にはJavaScriptプログラマではないよ、これらの関数を呼び出すこと立ち往生...と残念に男私はこのように "コーディング"のこの方法を続けていきたいと思っています。誰かが手掛かりを持っていますか?ありがとう
を。プログラムでアクセスできるプロパティを持つオブジェクトを使用します。 – Bergi
それでは、あなたが行っていないコードは*動作していますか?あなたの質問は何ですか?すべての関数がグローバルであれば 'window ['section' + name + 'Enter']'が動作し、 'func1();'を呼び出すことができます。 –
いいえ、全く動作しません。コンソールは何のエラーも投げなかった。 mousewheelイベントはトリガーです – jeffbkk