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

Image rotate (when enabled) doesn't work on mobile devices #249

Closed
pray4snow2 opened this issue Nov 26, 2016 · 1 comment
Closed

Image rotate (when enabled) doesn't work on mobile devices #249

pray4snow2 opened this issue Nov 26, 2016 · 1 comment

Comments

@pray4snow2
Copy link

pray4snow2 commented Nov 26, 2016

I have found that when I enable image rotation AND have the code present for uploading the image result to my server, the rotate buttons do not work on mobile devices only. The demo examples show one or the other, not both, so I am not sure if this is a bug or an issue on my end. The rotate left or rotate right buttons don't do anything on a mobile device, HOWEVER, they work fine in a desktop browser. My code is:

$( document ).ready(function() 
	{
		var $uploadCrop;
	
		function readFile(input) 
		{
			if (input.files && input.files[0]) 
			{
				var reader = new FileReader();          
				reader.onload = function (e) 
				{
					$uploadCrop.croppie('bind', {
						url: e.target.result,
						
					});
					$('.upload-demo').addClass('ready');
				}           
				reader.readAsDataURL(input.files[0]);
			}
		}
	
		$uploadCrop = $('#upload-demo').croppie({
			enableOrientation: true,        
			viewport:
				{
					width: 200,
					height: 200,
					type: 'circle'
				},
			boundary: 
				{
					width: 600,
					height: 400
				}
		});

		$('.vanilla-rotate').on('click', function(ev) 
			{
            	$uploadCrop.croppie('rotate', parseInt($(this).data('deg')));
        	});
    	$('#upload').on('change', function () { readFile(this); });
    	$('.upload-result').on('click', function (ev) {

        $uploadCrop.croppie('result', {
            type: 'canvas',
            size: 'original'
        }).then(function (resp) {
            $('#imagebase64').val(resp);
            $('#form').submit();
        });

    });

});

and the html:

<input type="file" id="upload" value="Choose a file">
<div id="upload-demo">/div>
<div class="actions" style="margin-left: auto; margin-right: auto; width:250px;">
	<button type="button" class="vanilla-rotate" data-deg="-90">Rotate Left</button>
	<button type="button" class="vanilla-rotate" data-deg="90">Rotate Right</button>
</div>                
<p><input type="hidden" id="imagebase64" name="imagebase64"><br />
<a href="#" class="upload-result"><img src="/images/upload.fw.png" align="center" width="230" height="52"></a><br />
</span>

Can anyone help determine if this is a bug or am I doing something very wrong?? I have tried googling this for hours on end, tried using touchstart instead of click thinking the mobile devices are not creating an actual click event, absolutely nothing I try helps. Everything functions perfect in a desktop browser (not Safari though), but the rotate buttons do nothing in a mobile device. The other stuff works fine (File pick and Upload) on a mobile device, just nothing on the rotate. I have also tried tons of different ways for the buttons as well, no help.

Any insight would be helpful. Thanks.

@thedustinsmith
Copy link
Contributor

I know this is old, I dropped the ball on responding to you. I doubt you're still having the problem, but you can try 2.5.2 and the issue may be fixed in there. Rotation has been changed quite a bit.

Sorry again.

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

No branches or pull requests

2 participants