daily pastebin goal
25%
SHARE
TWEET

Ace editor touch devices scrolling

a guest Mar 10th, 2015 400 Never
Upgrade to PRO!
ENDING IN00days00hours00mins00secs
 
  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
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top