私は公開モジュール パターンを利用しようとしてきましたが、css3 以外のカスタム スクロール バー用の関数を作成しようと考えました。
var sb=(function($){
//Private
var settings=function(props){
return{
wrapper: props.wrapper ? document.getElementById(props.wrapper):null,
thumb: props.thumb ? document.getElementById(props.thumb):null,
track: props.track ? document.getElementById(props.track):null,
left: props.left ? props.left:null,
right: props.right ? props.right:null,
contentWidth: props.contentWidth? props.contentWidth:null
};
};
var LOG=function(input){
console.log(input)
};
//Object Literal
return{
Log:LOG,
settings:settings
};
})(jQuery);
上記がモジュールです。私は次のように値を設定しています:
window.onload=function(){
sb.settings({wrapper:'bodyWrapper',thumb:'thumb',track:'track'});
}
ただし、テストしようとすると、「未定義」やその他のエラーが発生し続けます。console.log(settings.wrapper)
モジュール内で実行すると、 が返されますundefined
。どこが間違っているのか本当にわからないので、どんな助けでも大歓迎です。前もって感謝します