SHARE
TWEET

Ace editor touch devices scrolling

a guest Mar 10th, 2015 364 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var ace_editor = ace.edit('my-dom-id');
  2. var touch_start_x = 0;
  3. var touch_start_y = 0;
  4. $('.ace_scroller').on('touchstart', function(event){
  5.     touch_start_x = event.originalEvent.touches[0].pageX;
  6.     touch_start_y = event.originalEvent.touches[0].pageY;
  7. });
  8. $('.ace_scroller').on('touchmove', function(e){
  9.     var touch = e.originalEvent.touches[0] || e.originalEvent.changedTouches[0];
  10.     var x = touch.pageX - touch_start_x;
  11.     var y = touch.pageY - touch_start_y;
  12.     // now move
  13.     cms_ace_editor.renderer.scrollBy(x,y);
  14. });
RAW Paste Data
Top