Photoswipe无法在photoswipe.js第1070行读取未定义的属性"center"

Dan*_*nny 5 javascript image exception gallery photoswipe

我只是在尝试使用photoswipe,到目前为止,我还没有做过比简单实现一些非常小的(和理论上微不足道的调整)的入门演示副本更先进的东西.

我的图片库很好,我总共有4个项目,因为我只是想测试它.第一张照片将变焦和平移,所有这些都很棒.但是,当我切换图片时,我在这个帖子标题中得到了javascript错误.

我使用以下作为我的项目:

var items =[{"src":"/Images/Portfolio/Pieces/PhoenixFury.jpg","thumbnail":"/Images/Portfolio/Thumbs/PhoenixFury.jpg","msrc":"/Images/Portfolio/Thumbs/PhoenixFury.jpg","w":765,"h":1201,"title":"Phoenix\u0027s Fury","caption":"Illustration used for the cover of Lifeweaver","key":"Phoenix"},{"src":"/Images/Portfolio/Pieces/EnoreTower.jpg","thumbnail":"/Images/Portfolio/Thumbs/EnoreTower.jpg","msrc":"/Images/Portfolio/Thumbs/EnoreTower.jpg","w":765,"h":1200,"title":"Enore\u0027s Tower","caption":"Illustration used for the cover of Guardian\u0027s Peril","key":"Enore"},{"src":"/Images/Portfolio/Pieces/KenpoLogo.jpg","thumbnail":"/Images/Portfolio/Thumbs/KenpoLogo.jpg","msrc":"/Images/Portfolio/Thumbs/KenpoLogo.jpg","w":800,"h":966,"title":"Kenpo Karate Logo","caption":"Commissioned karate team logo for a team in Mexico with central american themes on the traditional Kenpo notion of a dragon and a tiger.","key":"Kenpo"},{"src":"/Images/Portfolio/Pieces/Quetzalcoatl.jpg","thumbnail":"/Images/Portfolio/Thumbs/Quetzalcoatl.jpg","msrc":"/Images/Portfolio/Thumbs/Quetzalcoatl.jpg","w":1600,"h":967,"title":"Quetzalcoatl","caption":"Central American ancient deity Quetzalcoatl, the feathered serpent.","key":"Quetzalcoatl"}];
Run Code Online (Sandbox Code Playgroud)

我添加了一些自定义属性,但我还没有对photoswipe做任何事情来尝试利用它们,所以我不认为这是问题所在.

我使用以下作为我的选择:

        var options = {

            history: false,
            focus: false,
            index: 0,//I can verify that 0,1,2,3 all load up correctly for an initial load
            showAnimationDuration: 0,
            hideAnimationDuration: 0

        };
Run Code Online (Sandbox Code Playgroud)

那么我只是做以下事情:

   var photoswipe = new PhotoSwipe(pswpElement, PhotoSwipeUI_Default, items, options);
        photoswipe.init();
Run Code Online (Sandbox Code Playgroud)

我有pswpElement,并简单地从photoswipe网站上删除了标记,所以它也应该排成一行.我真的很想知道我需要做些什么才能使它在换成新图像时能够正常工作.

我还验证了如果我从标题中删除u207(编码'),它并不能解决问题只是为了试图彻底解决问题.

Dmi*_*nov 8

确保index选项值是Integer,而不是String.parseInt( ... , 10)