5

I am just dabbling with photoswipe, and so far I haven't done anything more advanced than simply implementing a copy of the get started demo with a few very small (and theoretically insignificant tweaks).

My picture gallery comes up just fine, and I have a total of 4 items in it as I am just trying to test it. The first picture will zoom and pan and all of that just great. However, the moment I switch pictures, I get the javascript error in this post title.

I am using the following as my items:

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"}];

I have added a few custom attributes, but I haven't done anything yet with the photoswipe to try to utilize those, so I don't imagine that is the problem.

I am using the following as my options:

        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

        };

So then I just do the following:

   var photoswipe = new PhotoSwipe(pswpElement, PhotoSwipeUI_Default, items, options);
        photoswipe.init();

I have the pswpElement, and simply coppied the markup for that from the photoswipe site, so it should also be in line. I would really like to know what I need to do to make it so that it works when I swap to a new image.

I also verified that if I remove the u207 (encoded ') from the titles, it doesn't fix the problem just to try to be thorough about things.

Danny
  • 308
  • 1
  • 4
  • 12
  • Please provide a [reduced test case](http://css-tricks.com/reduced-test-cases/) (isolated example) that reproduces the problem. You may create it based on CodePens in PhotoSwipe documentation: [raw gallery](http://codepen.io/dimsemenov/pen/gbadPv), [gallery with thumbnails](http://codepen.io/dimsemenov/pen/ZYbPJM), [custom HTML content in slides](http://codepen.io/dimsemenov/pen/MYexrm). If you're not comfortable with CodePen, you may export code via `Share -> Export .zip`, and upload test case to your server. – Dmitry Semenov Jan 13 '15 at 09:00
  • Here's a code pen that is almost identical to my actual scenario. I am getting the problem in this one. http://codepen.io/anon/pen/dPvOzy I have wonky values in the show and hide durations in this fork as I copied some code where I was experimenting a bit with those values. – Danny Jan 14 '15 at 04:13
  • So how to reproduce the issue? I don't see any errors with codepen that you linked, even if animation duration is set to 0. – Dmitry Semenov Jan 14 '15 at 12:19
  • I just updated Chrome manually (thought it was supposed to take care of that for me). Once I did that, the code pen works. Thanks for looking and letting me know that it "works on your box" :) – Danny Jan 14 '15 at 13:48
  • Ok I can still reproduce it, but it is much better. I kind of intermittently get it. One time, I got it when I did a swipe down to close. Another time, I got it when I touched before the next image showed up. I pretty reliably seem to get a blank black screen when I do my first switch. Then I swipe back to the image I started on and navigate and it seems to work fine from there. I am still able to see the error, but it is not as easy to reproduce now that I updated chrome. – Danny Jan 14 '15 at 13:53
  • In case it is helpful, I am running windows 8.1 on a surface pro 3 using the latest version of Chrome. – Danny Jan 14 '15 at 15:04
  • what kind of pointer do you use? Mouse, touch, pen? Can you repeat the error on main demo page http://photoswipe.com ? – Dmitry Semenov Jan 14 '15 at 15:16
  • I can reproduce it with a mouse or with touch. I checked it on my laptop at work on a mouse in windows 7, and the code pen did not work for me. It is odd because the examples on photoswipe.com all work great. I can't figure out what is wrong with that code pen to make it unreliable. I have no problem getting it to crash in Chrome or IE 11 in Windows 8 or 7. – Danny Jan 15 '15 at 01:44

1 Answers1

10

Make sure that index option value is an Integer, not a String. parseInt( ... , 10)

Dmitry Semenov
  • 4,566
  • 2
  • 36
  • 39