0

I have a code working perfectly on a desktop device:

HTML:

<script type="text/javascript" src="http://code.jquery.com/ui/1.10.2/jquery-ui.js" />
</script><script type="text/javascript" src="my/tools/jquery.ui.touch-punch.min.js" />
<div id="time_roll">&nbsp;</div>

JS:

$('#time_roll').on('mousedown', function(e){
  x = e['clientX'];
  bgx = parseInt($('#time_roll').css('background-position-x'));
  $(window).on('mousemove', function(e){
    newx = e['clientX'];
    pos = bgx+newx-x;
    if (pos>0)       pos = 0;
    if (pos<-(24*60-1)) pos = -(24*60-1);
    $('#time_roll').css('background-position-x',pos);
    pos = -pos;
    h = parseInt(pos/60);
    m = pos%60;
    if (m.length<2) m = '0'+m;
    $('#time').val(h+':'+m);
  });
})

Short remark: my drag'n'drop working only in x-axis.

Unfortunately, DnD is not working on any mobile :(

Any thoughts?

Paul D. Waite
  • 96,640
  • 56
  • 199
  • 270
Roman Matveev
  • 563
  • 1
  • 6
  • 22
  • When you say "is not working" can you be more specific? What device(s) have you tested it on and are there any error messages? If you're on an iOS device, try enabling the debug console. – nullability May 23 '13 at 17:56

1 Answers1

0

You might be having a problem with trying to manipulate the background-position-x property. It is not a standard property and isn't supported by some browsers (e.g. Firefox). You should instead parse background-position for x and y values, and manipulate those.

See Is background-position-x (background-position-y) a standard W3C CSS property?

Community
  • 1
  • 1
nullability
  • 10,545
  • 3
  • 45
  • 63