JAN
5TH
2014

Creating a PhoneGap/Cordova 3.0 app in Eclipse

Android | Tags:

There are several steps required to get Phonegap 3.0+ working with Eclipse, and the documentation is not always clear..

Here is what worked for me: Read more..

DEC
9TH
2013

Dynamically adding items to PhotoSwype

Apps | Tags:

I was playing around with a small test app that used PhotoSwype, and ran into a small issue when trying to dynamically add images to the gallary.

If you build the photoswype script yourself there is a patch that will get you 90% of the way, but it fails when you have already scrolled to the end of the gallary and then want to push another image.  Simply calling the show method seems to fix this issue, so if anyone ran into this issue here is some code that might help.

          addImage: function (obj) {
            this.originalImages.push(obj);

            // Add click handler to the link
            Util.Events.add(obj, 'click', PhotoSwipe.onTriggerElementClick.bind(this));

            // Create image and add it to the cached images
            this.cache.images.push(
                new Code.PhotoSwipe.Image.ImageClass(
                    obj,
                    this.settings.getImageSource(obj),
                    this.settings.getImageCaption(obj),
                    this.settings.getImageMetaData(obj)
                )
            );

            //images now added, but if we are at the last image then the dom is not correctly updated (image will be blank until you scroll back)
            //this line forces an update
            this.carousel.show(this.currentIndex);
        },

You can call this as follows:

  var image = {
   url: 'yourimage.png', caption: 'Your Image Caption'
}
photoSwipeInstance.addImage(image);

Categories

Tags

Links

ArticleMS