2

これがページ変更時に写真スワイプの「homeSlider」インスタンスを切り離さない理由についてのアイデアはありますか? 私は Photoswipe docs に従っていると思いますが、インスタンスをデタッチしていないようです。私はJqueryモバイルを使用しているため、「pageshow」/「pagehide」です。ページに戻ってスライドショーがフリーズすると、「Code.PhotoSwipe.activateInstance: Unable to active instance as another instance is already active for this target」というエラーがスローされます。

(function(window, Util, PhotoSwipe){
    $(document).ready(function(){

        $('#home').live('pageshow', function(e){    

                var 
                currentPage = $(e.target),
                homeSlider;
                homeSlider = PhotoSwipe.attach(
                window.document.querySelectorAll('#slider a'),
                {
                    target: window.document.querySelectorAll('#PhotoSwipeTarget')[0],
                    loop: true,
                    preventHide: true,
                    autoStartSlideshow: true,
                    captionAndToolbarHide: true,
                    margin: 0,
                }
                ); // PhotoSwipe.attach         
                homeSlider.show(0);     
                return true;    

            });
            $('#home').live('pagehide', function(e){

                var 
                currentPage = $(e.target),
                homeSlider = PhotoSwipe.getInstance(currentPage.attr('id'));

                if (typeof homeSlider != "undefined" && homeSlider != null) {
                    PhotoSwipe.detatch(homeSlider);
                }

                return true;

            }); 

        }); // $(document).ready(function(e){
    }(window, window.Code.Util, window.Code.PhotoSwipe)); // function(window, util, PhotoSwipe)
4

0 に答える 0