Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mobile touch events like Photoswipe #25

Open
dlewand691 opened this issue Feb 1, 2016 · 16 comments
Open

Mobile touch events like Photoswipe #25

dlewand691 opened this issue Feb 1, 2016 · 16 comments

Comments

@dlewand691
Copy link

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!

@johannpinson
Copy link

+1

@dgobnto
Copy link

dgobnto commented Apr 26, 2016

+1 ;)

@sam-g-roberts
Copy link

+1

3 similar comments
@daslicht
Copy link

+1

@user928
Copy link

user928 commented Sep 26, 2016

+1

@ghost
Copy link

ghost commented Nov 27, 2016

+1

@dlewand691
Copy link
Author

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

@Sanabria
Copy link

+1

@xrat
Copy link

xrat commented May 15, 2017

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?

@enkota
Copy link

enkota commented Sep 5, 2017

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

@shangul
Copy link

shangul commented Sep 7, 2017

+1

@nicolas-t
Copy link
Owner

More informations regarding swipe, and how it can be done :
#68

@yannicgraeser
Copy link

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 :(

@isospin
Copy link

isospin commented Dec 9, 2017

+1

@johansmitsnl
Copy link

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.

@nicolas-t nicolas-t changed the title Mobile touch events like Photoswipe - please add Mobile touch events like Photoswipe May 27, 2019
@nicolas-t
Copy link
Owner

nicolas-t commented May 27, 2019

@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
                }
            });

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests