2011-12-30 6 views
3

私はビデオギャラリーを一緒にハックしようとしています。私はjQueryを使用して、パネルを外にスライドさせるようにしています シンプルです。また、サムネイルをスクロールするためにjQueryも使用しています。彼らは両方とも美しく動作します。問題は、スクロールアウトパネル内でスクロールする必要があることですが、スクロールすることはできません。私はそれがドキュメントの準備ができていることと、ウィンドウが読み込まれていることの2つの機能と関係していると思います。私はjQueryを初めて使う理由はわかりません。いずれにせよこれを助けることができます。jQueryドキュメントはウィンドウのロードと競合していますか?

ここにスライドアウトパネル機能があります。

彼女はスクロール機能です。

<script> 
jQuery.noConflict() 
(function($){ 
window.onload=function(){ 
$("#tS2").thumbnailScroller({ 
    scrollerType:"clickButtons", 
    scrollerOrientation:"horizontal", 
    scrollSpeed:2, 
    scrollEasing:"easeOutCirc", 
    scrollEasingAmount:600, 
    acceleration:4, 
    scrollSpeed:800, 
    noScrollCenterSpace:10, 
    autoScrolling:0, 
    autoScrollingSpeed:2000, 
    autoScrollingEasing:"easeInOutQuad", 
    autoScrollingDelay:500 
}); 
} 
})(jQuery); 
</script> 

ここでは、誰とでも矛盾するものはありますか?

ここに全体のHTMLがあります。

<html> 

<head> 
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 
<title>Vertical Sliding Info Panel With jQuery</title> 
<link rel="stylesheet" href="style.css" type="text/css" media="screen" /> 
<link href="jquery.thumbnailScroller.css" rel="stylesheet" /> 
<script type="text/javascript" src="http://jqueryjs.googlecode.com/files/jquery-1.3.2.js"></script> 
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.5/jquery.min.js"></script> 
<script src="jquery-ui-1.8.13.custom.min.js"></script> 

<script> 
$(document).ready(function(){ 
$(".trigger").click(function(){ 
    $(".panel").toggle("fast"); 
    $(this).toggleClass("active"); 
    return false; 
}); 
}); 
</script> 
</head> 

<body> 

<div class="panel"> 
<div> 
<div id="tS2" class="jThumbnailScroller"> 
<div class="jTscrollerContainer"> 
    <div class="jTscroller"> 
     <a href="#"><img src="thumbs/img1.jpg" /></a> 
     <a href="#"><img src="thumbs/img2.jpg" /></a> 
     <a href="#"><img src="thumbs/img3.jpg" /></a> 
     <a href="#"><img src="thumbs/img4.jpg" /></a> 
     <a href="#"><img src="thumbs/img5.jpg" /></a> 
     <a href="#"><img src="thumbs/img6.jpg" /></a> 
     <a href="#"><img src="thumbs/img7.jpg" /></a> 
     <a href="#"><img src="thumbs/img8.jpg" /></a> 
     <a href="#"><img src="thumbs/img9.jpg" /></a> 
     <a href="#"><img src="thumbs/img10.jpg" /></a> 
     <a href="#"><img src="thumbs/img11.jpg" /></a> 
     <a href="#"><img src="thumbs/img12.jpg" /></a> 
     <a href="#"><img src="thumbs/img13.jpg" /></a> 
     <a href="#"><img src="thumbs/img14.jpg" /></a> 
     <a href="#"><img src="thumbs/img15.jpg" /></a> 
     <a href="#"><img src="thumbs/img16.jpg" /></a> 
     <a href="#"><img src="thumbs/img17.jpg" /></a> 
     <a href="#"><img src="thumbs/img18.jpg" /></a> 
     <a href="#"><img src="thumbs/img19.jpg" /></a> 
     <a href="#"><img src="thumbs/img20.jpg" /></a> 
    </div> 
</div> 
<a href="#" class="jTscrollerPrevButton"></a> 
<a href="#" class="jTscrollerNextButton"></a> 
</div> 
<!-- thumbnail scroller markup end --> 

<script> 
/* jQuery.noConflict() for using the plugin along with other libraries. 
You can remove it if you won't use other libraries (e.g. prototype, scriptaculous etc.) or 
if you include jQuery before other libraries in yourdocument's head tag. 
[more info: http://docs.jquery.com/Using_jQuery_with_Other_Libraries] */ 
jQuery.noConflict(); 
/* calling thumbnailScroller function with options as parameters */ 
(function($){ 
window.onload=function(){ 
$("#tS2").thumbnailScroller({ 
    scrollerType:"clickButtons", 
    scrollerOrientation:"horizontal", 
    scrollSpeed:2, 
    scrollEasing:"easeOutCirc", 
    scrollEasingAmount:600, 
    acceleration:4, 
    scrollSpeed:800, 
    noScrollCenterSpace:10, 
    autoScrolling:0, 
    autoScrollingSpeed:2000, 
    autoScrollingEasing:"easeInOutQuad", 
    autoScrollingDelay:500 
}); 
} 
})(jQuery); 
</script> 
<!-- thumbnailScroller script --> 
<script src="jquery.thumbnailScroller.js"></script> 
</div> 
</div> 
<a class="trigger" href="#">infos</a> 

</body> 
</html> 
+0

含んあなたのjQueryを使って何が起こっていますか? –

答えて

1

サムネイルScrollerプラグインは、サムのラッパーの寸法を計算する必要があるようです。あなたの場合、ラッパーは最初は表示されず、プラグインが混乱する可能性があります。

プラグインを実行した後にのみ.panel要素を非表示にすることができます。

jQuery.noConflict(); 
/* calling thumbnailScroller function with options as parameters */ 
(function($){ 
    $(document).ready(function(){ 
     $(".trigger").click(function(){ 
      $(".panel").toggle("fast"); 
      $(this).toggleClass("active"); 
      return false; 
     }); 
    }); 
    window.onload=function(){ 
     $("#tS2").thumbnailScroller({ 
      scrollerType:"clickButtons", 
      scrollerOrientation:"horizontal", 
      scrollSpeed:2, 
      scrollEasing:"easeOutCirc", 
      scrollEasingAmount:600, 
      acceleration:4, 
      scrollSpeed:800, 
      noScrollCenterSpace:10, 
      autoScrolling:0, 
      autoScrollingSpeed:2000, 
      autoScrollingEasing:"easeInOutQuad", 
      autoScrollingDelay:500 
     }); 

     // Hide the .panel only now : 
     $(".panel").hide(); 
    }; 
})(jQuery); 

(あなたが.panelが最初に表示されるように、あなたのCSSを変更する必要があります)

+0

パーフェクトありがとうございます。それは、ページが読み込まれたときに少しずつ小さな点を点滅させますが、私はその点で暮らすことができます。十分な担当者がいれば、私はこれを1つ上げます。 – Jakeray

+0

点滅を防ぐには、.panelをvisibility:hiddenに初期化して、ディメンションが正常であるようにすることができます。そして 'hide()'の代わりに 'css({visibility: 'visible'、display: 'none'})'を使用します。 –

+0

もう一度ありがとうございます。それはもはや点滅しませんでした。 – Jakeray

1

がdocument.readyがあなたのDOMとすぐに実行されます/文書は準備ができているが、window.loadは、すべてのオブジェクト(画像/テキスト)momeryにロードされた後にのみ実行されます。

私は複数の画像のリストのためにscrollerを作成するのにdocument.readyを使用していたが、画像の一部が大きかったので画像がロードされる前にdocument.readyが起動され、直面した問題..

私は後にのみトリガーされますwindow.load私のスクロールの作成プロセスで今window.loadでそれを変えので、後で際に適切にメモリ内のすべての画像をロード...これが役立つ

希望あなたは解決策を得るために。

+0

私のイメージスクロールは、スライドアウトパネルの外側で大きく機能します。しかし、私がそれをdiv内に置くと、パネルからのスライドアウトは1つのイメージとスクロールしか表示されません。 – Jakeray

0

2つのdocument.ready関数を同じページで使用しているのはなぜですか?それは間違いなく紛争を起こすでしょう。最初にスクリプト宣言を避けて試してみてください。

スクリプトタグ内にこのjsコードが必要です。これはあなたのために働くでしょう。まず

jQuery.noConflict(); /* calling thumbnailScroller function with options as parameters*/ 
(function($){ 
    $(".trigger").click(function(){ 
     $(".panel").toggle("fast"); 
     $(this).toggleClass("active"); 
     return false; 
    }); 


window.onload=function(){ 
    $("#tS2").thumbnailScroller({ 
    scrollerType:"clickButtons", 
    scrollerOrientation:"horizontal", 
    scrollSpeed:2, 
    scrollEasing:"easeOutCirc", 
    scrollEasingAmount:600, 
    acceleration:4, 
    scrollSpeed:800, 
    noScrollCenterSpace:10, 
    autoScrolling:0, 
    autoScrollingSpeed:2000, 
    autoScrollingEasing:"easeInOutQuad", 
    autoScrollingDelay:500 
    }); 
} 
})(jQuery); 
+0

これは、パネルのスライドをまったく停止させます。 – Jakeray

+0

2つのdocument.ready関数を使用すると、間違いなく競合は発生しません。関数は、イベントリスナーに順番に登録され、ドキュメントの準備ができたらその順序で実行されます。 –

0

$(".trigger").click(...)のバインディングをダブルクリックイベントを削除し、唯一の二つが必要とされています。次に、window.onload内でthumbnailScrollerの初期化後にこのバインディングを移動しようとすると、DOM readyイベントの後にwindow.onloadが多く発生します。そして、不要なものとしてwindow.onloadを囲むように(function($){を取り除く。これを試してみてください:

$(window).load(function() { 
    // Initialize scroller 
    $("#tS2").thumbnailScroller({ ... }); 

    // Initialize panel 
    $(".trigger").click(function() { 
     $(".panel").toggle("fast"); 
     $(this).toggleClass("active"); 
     return false; 
    }); 
}); 
+0

これは間違いなくきれいなコードですが、同じ結果が得られます。 – Jakeray

+0

私のパネルが飛び散らなければならないのですが、内部のスクロールはスクロールせずに1つの画像しか表示しません。 – Jakeray

+0

おそらく、これはあなたのスクロールが初期化の瞬間までに隠されていて、jQueryのwidth()関数が隠し画像に対して0幅を返すからです。 '.css( 'width')'は動作するはずですが、この場合はプラグインコードを微調整する必要があります。わからないかもしれませんが、イメージの 'width'属性と' height'属性を設定すると、そのジョブを実行できます。 – dfsq

関連する問題