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

Add pause() function. #84

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open

Add pause() function. #84

wants to merge 5 commits into from

Conversation

Growiel
Copy link

@Growiel Growiel commented May 18, 2016

The pause() function allows the user to pause the cropping by unbinding
the events but keeping the css, html and data alive.

It can be re-enabled by another call to pause(). You can specify a
boolean for force the pause or unpause regardless of previous status.

The pause() function allows the user to pause the cropping by unbinding
the events but keeping the css, html and data alive.

It can be re-enabled by another call to pause(). You can specify a
boolean for force the pause or unpause regardless of previous status.
@Growiel Growiel closed this May 19, 2016
Using hammerJS's .off() does not restore native events and as such
scrolling the on the image on mobile was impossible.

The pause() method now uses hammerit.get('pinch').set({enable: false});
(or true) to correctly toggle HammerJS on and off instead of re-creating
a new instance each time like I previously did.

This required moving some stuff around because there is no such thing as
pausing a receiver withtout HammgerJS.
@Growiel Growiel reopened this May 19, 2016
@Growiel
Copy link
Author

Growiel commented May 19, 2016

Reopening with the latest version. This already includes the fix for HammerJS in PR85, but I still provided the PR85 as standalone in case you want to include the fix but not the pause() method.

Turns out that HammerJS's .off() method does not restore native events, so scrolling was impossible. I fixed it by using hammerit.get('pinch').set({enable: false}); (or true) in the pause method instead.

Since the first version I also added the ability to start the cropbox paused with the "paused" option.
I updated the readme accordingly.

Tried it on Chrome, FF, Chrome Android, Safari iOS and IE9 without any issues.

Added handling of the mousewheel event when using HammerJS. By adding an
_unbindMouseWheel() method and calling it as needed in pause().
@Growiel
Copy link
Author

Growiel commented May 19, 2016

Hopefully last commit on this: added correct handling of the mousewheel event when using HammerJS.
For performance reasons in my project I only load mousewheel on desktop and HammerJS on mobile, but I took the time to test it out with both and fixed what needed to be fixed.

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

Successfully merging this pull request may close these issues.

1 participant