Chocolat icon indicating copy to clipboard operation
Chocolat copied to clipboard

Mobile touch events like Photoswipe

Open dlewand691 opened this issue 9 years ago • 16 comments

Love the plug-in but could really use some of the touch event capability similar to Photoswipe. Any thoughts on integrating something like this? Has it been done with any examples? Thank you!

dlewand691 avatar Feb 01 '16 22:02 dlewand691

+1

johannpinson avatar Mar 01 '16 14:03 johannpinson

+1 ;)

dgobnto avatar Apr 26 '16 01:04 dgobnto

+1

sam-g-roberts avatar Jun 29 '16 16:06 sam-g-roberts

+1

daslicht avatar Sep 21 '16 15:09 daslicht

+1

user928 avatar Sep 26 '16 11:09 user928

+1

ghost avatar Nov 27 '16 11:11 ghost

This new plugin might give some inspiration on how to add mobile touch events: http://desmonding.me/zooming/

dlewand691 avatar Dec 23 '16 14:12 dlewand691

+1

Sanabria avatar Jan 16 '17 20:01 Sanabria

Am I right that this issue is the cause for the fact that Chocolat is almost not usable on small mobile devices because there is no way to move the image when zoomed?

xrat avatar May 15 '17 14:05 xrat

@xrat This and that you cannot swipe gesture to the next slide easily.

enkota avatar Sep 05 '17 16:09 enkota

+1

shangul avatar Sep 07 '17 14:09 shangul

More informations regarding swipe, and how it can be done : https://github.com/nicolas-t/Chocolat/issues/68

nicolas-t avatar Sep 10 '17 16:09 nicolas-t

Am I right that this issue is the cause for the fact that Chocolat is almost not usable on small mobile devices because there is no way to move the image when zoomed?

I can't use this otherwise very cool plugin because of this :(

yannicgraeser avatar Oct 30 '17 14:10 yannicgraeser

+1

isospin avatar Dec 09 '17 20:12 isospin

This is my piece of code inspired by the comments:

$(document).ready(function () {
    $('.chocolat-parent').Chocolat({
        imageSize: 'contain',
        loop: true,
        enableZoom: false,
        afterImageLoad: function () {
            const chocolat = this;
            const hammertime = new Hammer(this.elems.img[0], {});
            hammertime.on('pan', function (ev) {
                if (ev.isFinal) {

                   // FIXME needs proper API for calling the zoom function (does not work properly)
                    chocolat.zoomOut();

                    if (ev.additionalEvent === 'panleft') {
                        chocolat.api().prev();
                    } else if (ev.additionalEvent === 'panright') {
                        chocolat.api().next();
                    }
                }
            });
            hammertime.on('doubletap', function (ev) {
                if (ev.isFinal) {
                    // FIXME needs proper API for calling the zoom function (does not work properly)
                    chocolat.zoomIn({pageX: ev.center.x, pageY: ev.center.y});
                }
            });
        }
    });
});

The only part missing is the Zoom implementation. It seems the API does not have zoom exposed and this implementation does not work. Suggestions?

Agree with @nicolas-t to not implement zoom because it is easy to implement with the library os choice.

johansmitsnl avatar May 26 '19 20:05 johansmitsnl

@johansmitsnl You could totally add zoom methods to the api. A pull request would be very welcome.

At this line :
https://github.com/nicolas-t/Chocolat/blob/master/src/js/jquery.chocolat.js#L663

Something like :

zoomIn: function(e) {
    return that.zoomIn(e)
},

zoomOut: function(duration) {
    return that.zoomOut(duration)
},

Then you would have to call it like this :

            hammertime.on('doubletap', function (ev) {
                if (ev.isFinal) {
                    chocolat.api().zoomIn(ev.srcEvent); // pass source event ev.srcEvent
                }
            });

nicolas-t avatar May 27 '19 10:05 nicolas-t