0

前提・実現したいこと

1ページ内でOwlCarousel と Colorbox を使用しています。
そして、「Zoom」ボタンをクリックし 「Colorbox」を操作したあと、ポップアップ・ウィンドウを閉じたら、「OwlCarousel」のメイン画像部分が反復されます。

「Colorbox」を操作したあと、「OwlCarousel」のメイン画像部分が反復しないようにするにはどうすればよろしいでしょうか。

ご教授の程、よろしくお願いします。

確認用のURL

http://www.ks-clothing.click/women/tops-blouses/black-nolita-cami.html

該当のソースコード

<?php
$_product = $this->getProduct();
$_helper = $this->helper('catalog/output');
?>

<div id="sync1" class="owl-carousel">
    <?php $i=0; foreach ($this->getGalleryImages() as $_image): ?>
        <?php if ($this->isGalleryImageVisible($_image)): ?>
            <div class="item">
                <div class="cloud-zoom" rel="position: 'inside' , showTitle: false" href="<?php echo $this->getGalleryImageUrl($_image); ?>">
                    <img src="<?php echo $this->getGalleryImageUrl($_image); ?>" alt="<?php echo $this->escapeHtml($this->getImageLabel()) ?>" title="<?php echo $this->escapeHtml($this->getImageLabel()); ?>" />
                </div>
                <a class="gallery" href="<?php echo $this->getGalleryImageUrl($_image); ?>">ZOOM</a>
            </div>
        <?php endif; ?>
        <?php $i++; endforeach; ?>
</div>

<?php if (count($this->getGalleryImages()) > 0): ?>
    <div id="sync2" class="owl-carousel">
        <?php $i=0; foreach ($this->getGalleryImages() as $_image): ?>
            <?php if ($this->isGalleryImageVisible($_image)): ?>
                <div class="item">
                    <img src="<?php echo $this->helper('catalog/image')->init($this->getProduct(), 'thumbnail', $_image->getFile())->resize(75); ?>" width="75" height="75" alt="<?php echo $this->escapeHtml($_image->getLabel()) ?>" />
                </div>
            <?php endif; ?>
            <?php $i++; endforeach; ?>
    </div>
<?php endif; ?>

<script type="text/javascript">
    //<![CDATA[
    jQuery(document).ready(function($){
        $(function(){
            $(".gallery").colorbox({
                rel:'slideshow',
                maxWidth:"100%",
                maxHeight:"100%",
                opacity: 0.5
            });

            var sync1 = $("#sync1");
            var sync2 = $("#sync2");

            sync1.owlCarousel({
                singleItem : true,
                slideSpeed : 1000,
                navigation: true,
                pagination:false,
                afterAction : syncPosition,
                responsiveRefreshRate : 200,
            });

            sync2.owlCarousel({
                items : 15,
                itemsDesktop      : [1199,10],
                itemsDesktopSmall     : [979,10],
                itemsTablet       : [768,8],
                itemsMobile       : [479,4],
                pagination:false,
                responsiveRefreshRate : 100,
                afterInit : function(el){
                    el.find(".owl-item").eq(0).addClass("synced");
                }
            });

            function syncPosition(el){
                var current = this.currentItem;
                $("#sync2")
                    .find(".owl-item")
                    .removeClass("synced")
                    .eq(current)
                    .addClass("synced")
                if($("#sync2").data("owlCarousel") !== undefined){
                    center(current)
                }
            }

            $("#sync2").on("click", ".owl-item", function(e){
                e.preventDefault();
                var number = $(this).data("owlItem");
                sync1.trigger("owl.goTo",number);
            });

            function center(number){
                var sync2visible = sync2.data("owlCarousel").owl.visibleItems;
                var num = number;
                var found = false;
                for(var i in sync2visible){
                    if(num === sync2visible[i]){
                        var found = true;
                    }
                }

                if(found===false){
                    if(num>sync2visible[sync2visible.length-1]){
                        sync2.trigger("owl.goTo", num - sync2visible.length+2)
                    }else{
                        if(num - 1 === -1){
                            num = 0;
                        }
                        sync2.trigger("owl.goTo", num);
                    }
                } else if(num === sync2visible[sync2visible.length-1]){
                    sync2.trigger("owl.goTo", sync2visible[1])
                } else if(num === sync2visible[0]){
                    sync2.trigger("owl.goTo", num-1)
                }

            }
        });
    });
    //]]>
</script>

補足情報

jquery-1.10.2.min.js
Owl Carousel
Colorbox

5
  • 「jQuery(document).ready(function($){」って必要なんでしょうか。見たことが無いです。
    – htb
    2016年6月28日 10:16
  • 私は最近、気になるリンクを見つけました。 $ を jQuery に書き換えれば動く curious-everything.com/204-entry.html 2016年6月28日 10:37
  • colorboxを有効化するコードが質問に書かれたものと確認用URLのものと違っているのですが、どちらが新しいのでしょうか・・・?少なくとも確認用URLではcolorboxが動作していないように思います。
    – unarist
    2016年6月28日 11:23
  • 質問者さんが困っている問題と同じかどうかわかりませんが、不自然な挙動は再現できました。原因はまだ不明ですが参考までに: jsfiddle.net/777b3bmx/2
    – unarist
    2016年6月28日 12:46
  • co‌​lorboxが動作していなかったのは、何処が原因か調べていたためです。 依然、問題を解決できていません。ご教授、ご協力よろしくお願いします。 2016年6月29日 0:50

0

この質問に回答するには、ログインする必要があります。

のタグが付いた他の質問を参照する。