pan & tilt with one finger
426442
function(e) {
    this.touch.cur = 'dragging';
    var delta = 0;
    if (this.touch.lastY && (e.gesture.direction == 'up' || e.gesture.direction == 'down')) {
      //tilt
      delta = e.gesture.deltaY - this.touch.lastY;
      this.angleX += delta;
    } else if (this.touch.lastX && (e.gesture.direction == 'left' || e.gesture.direction == 'right')) {
      //pan
      delta = e.gesture.deltaX - this.touch.lastX;
      this.angleZ += delta;
    }
    if (delta)
      this.onDraw();
    this.touch.lastX = e.gesture.deltaX;
    this.touch.lastY = e.gesture.deltaY;
  }
1289850
def rotate(self, count=1, with_pane_before_only=False, with_pane_after_only=False):
        
        # Create (split, index, pane, weight) tuples.
        items = []
        current_pane_index = None

        for s in self.splits:
            for index, item in enumerate(s):
                if isinstance(item, Pane):
                    items.append((s, index, item, s.weights[item]))
                    if item == self.active_pane:
                        current_pane_index = len(items) - 1

        # Only before after? Reduce list of panes.
        if with_pane_before_only:
            items = items[current_pane_index - 1:current_pane_index + 1]

        elif with_pane_after_only:
            items = items[current_pane_index:current_pane_index + 2]

        # Rotate positions.
        for i, triple in enumerate(items):
            split, index, pane, weight = triple

            new_item = items[(i + count) % len(items)][2]

            split[index] = new_item
            split.weights[new_item] = weight
429376
protected static void adjustPan (Line line, float pan)
    {
        try {
            FloatControl control = (FloatControl) line.getControl(FloatControl.Type.PAN);
            control.setValue(pan);
        } catch (Exception e) {
            log.debug("Cannot set pan on line: " + e);
        }
    }
911513
def cmd_pan(self, x=None, y=None, ch=None):
        
        viewer = self.get_viewer(ch)
        if viewer is None:
            self.log("No current viewer/channel.")
            return

        pan_x, pan_y = viewer.get_pan()

        if x is None and y is None:
            self.log("x=%f y=%f" % (pan_x, pan_y))

        else:
            if x is not None:
                if y is None:
                    y = pan_y
            if y is not None:
                if x is None:
                    x = pan_x
            viewer.set_pan(x, y)
387447
def pan_delta(self, d):
        """"""
        dx, dy = d

        pan_x, pan_y = self.pan
        zoom_x, zoom_y = self._zoom_aspect(self._zoom)

        self.pan = (pan_x + dx / zoom_x, pan_y + dy / zoom_y)
        self.update()
857777
function(xy) {
        if(this.panned) {
            var res = null;
            if (this.kinetic) {
                res = this.kinetic.end(xy);
            }
            this.map.pan(
                this.handler.last.x - xy.x,
                this.handler.last.y - xy.y,
                {dragging: !!res, animate: false}
            );
            if (res) {
                var self = this;
                this.kinetic.move(res, function(x, y, end) {
                    self.map.pan(x, y, {dragging: !end, animate: false});
                });
            }
            this.panned = false;
        }
    }
1208569
function handle2pan(e){
            var v = {
              x: e.originalEvent.pageX - $panner.offset().left - $panner.width()/2,
              y: e.originalEvent.pageY - $panner.offset().top - $panner.height()/2
            }

            var r = options.panDragAreaSize;
            var d = Math.sqrt( v.x*v.x + v.y*v.y );
            var percent = Math.min( d/r, 1 );

            if( d < options.panInactiveArea ){
              return {
                x: NaN,
                y: NaN
              };
            }

            v = {
              x: v.x/d,
              y: v.y/d
            };

            percent = Math.max( options.panMinPercentSpeed, percent );

            var vnorm = {
              x: -1 * v.x * (percent * options.panDistance),
              y: -1 * v.y * (percent * options.panDistance)
            };

            return vnorm;
          }
78776
function _handleMove(e) {
      if (!_doubleTap && _settings('touchEnabled')) {
        var x0,
            x1,
            y0,
            y1,
            cos,
            sin,
            end,
            pos0,
            pos1,
            diff,
            start,
            dAngle,
            dRatio,
            newStageX,
            newStageY,
            newStageRatio,
            newStageAngle;

        _downTouches = e.touches;
        _isMoving = true;

        if (_movingTimeoutId)
          clearTimeout(_movingTimeoutId);

        _movingTimeoutId = setTimeout(function() {
          _isMoving = false;
        }, _settings('dragTimeout'));

        switch (_touchMode) {
          case 1:
            pos0 = position(_downTouches[0]);
            x0 = pos0.x;
            y0 = pos0.y;

            diff = _camera.cameraPosition(
              x0 - _startTouchX0,
              y0 - _startTouchY0,
              true
            );

            newStageX = _startCameraX - diff.x;
            newStageY = _startCameraY - diff.y;

            if (newStageX !== _camera.x || newStageY !== _camera.y) {
              _lastCameraX = _camera.x;
              _lastCameraY = _camera.y;

              _camera.goTo({
                x: newStageX,
                y: newStageY
              });

              _self.dispatchEvent('mousemove',
                sigma.utils.mouseCoords(e, pos0.x, pos0.y));

              _self.dispatchEvent('drag');
            }
            break;
          case 2:
            pos0 = position(_downTouches[0]);
            pos1 = position(_downTouches[1]);
            x0 = pos0.x;
            y0 = pos0.y;
            x1 = pos1.x;
            y1 = pos1.y;

            start = _camera.cameraPosition(
              (_startTouchX0 + _startTouchX1) / 2 -
                sigma.utils.getCenter(e).x,
              (_startTouchY0 + _startTouchY1) / 2 -
                sigma.utils.getCenter(e).y,
              true
            );
            end = _camera.cameraPosition(
              (x0 + x1) / 2 - sigma.utils.getCenter(e).x,
              (y0 + y1) / 2 - sigma.utils.getCenter(e).y,
              true
            );

            dAngle = Math.atan2(y1 - y0, x1 - x0) - _startTouchAngle;
            dRatio = Math.sqrt(
              (y1 - y0) * (y1 - y0) + (x1 - x0) * (x1 - x0)
            ) / _startTouchDistance;

            // Translation:
            x0 = start.x;
            y0 = start.y;

            // Homothetic transformation:
            newStageRatio = _startCameraRatio / dRatio;
            x0 = x0 * dRatio;
            y0 = y0 * dRatio;

            // Rotation:
            newStageAngle = _startCameraAngle - dAngle;
            cos = Math.cos(-dAngle);
            sin = Math.sin(-dAngle);
            x1 = x0 * cos + y0 * sin;
            y1 = y0 * cos - x0 * sin;
            x0 = x1;
            y0 = y1;

            // Finalize:
            newStageX = x0 - end.x + _startCameraX;
            newStageY = y0 - end.y + _startCameraY;

            if (
              newStageRatio !== _camera.ratio ||
              newStageAngle !== _camera.angle ||
              newStageX !== _camera.x ||
              newStageY !== _camera.y
            ) {
              _lastCameraX = _camera.x;
              _lastCameraY = _camera.y;
              _lastCameraAngle = _camera.angle;
              _lastCameraRatio = _camera.ratio;

              _camera.goTo({
                x: newStageX,
                y: newStageY,
                angle: newStageAngle,
                ratio: newStageRatio
              });

              _self.dispatchEvent('drag');
            }

            break;
        }

        e.preventDefault();
        return false;
      }
    }
474239
private void touchFixed() {
        assert this.dense;
        assert this.level == 0;
        assert this.schedule;
        while (this.touched < this.trail.size()) {
            final int lit = this.trail.get(this.touched++);
            assert val(lit) > 0;
            assert var(lit).level() == 0;
            final CLOccs os = occs(lit);
            for (final CLClause c : os) {
                for (int i = 0; i < c.lits().size(); i++) {
                    final int other = c.lits().get(i);
                    if (val(other) == VALUE_TRUE) { continue; }
                    assert other != lit;
                    touch(other);
                }
            }
        }
    }
136523
def on_touch_move(self, touch):
        """"""
        if touch is not self._touch:
            return False
        self.pos = (
            touch.x + self.x_down,
            touch.y + self.y_down
        )
        return True
321107
private void offsetMenu(int offsetPixels) {
        if (!mOffsetMenu || mMenuSize == 0) {
            return;
        }

        final int width = getWidth();
        final int height = getHeight();

        final int menuSize = mMenuSize;
        final int sign = (int) (mOffsetPixels / Math.abs(mOffsetPixels));
        final float openRatio = Math.abs(mOffsetPixels) / menuSize;
        final int offset = (int) (-0.25f * ((1.0f - openRatio) * menuSize) * sign);

        switch (getPosition()) {
            case LEFT: {
                if (USE_TRANSLATIONS) {
                    if (offsetPixels > 0) {
                        mMenuContainer.setTranslationX(offset);
                    } else {
                        mMenuContainer.setTranslationX(-menuSize);
                    }

                } else {
                    mMenuContainer.offsetLeftAndRight(offset - mMenuContainer.getLeft());
                    mMenuContainer.setVisibility(offsetPixels == 0 ? INVISIBLE : VISIBLE);
                }
                break;
            }

            case RIGHT: {
                if (USE_TRANSLATIONS) {
                    if (offsetPixels != 0) {
                        mMenuContainer.setTranslationX(offset);
                    } else {
                        mMenuContainer.setTranslationX(menuSize);
                    }

                } else {
                    final int oldOffset = mMenuContainer.getRight() - width;
                    final int offsetBy = offset - oldOffset;
                    mMenuContainer.offsetLeftAndRight(offsetBy);
                    mMenuContainer.setVisibility(offsetPixels == 0 ? INVISIBLE : VISIBLE);
                }
                break;
            }

            case TOP: {
                if (USE_TRANSLATIONS) {
                    if (offsetPixels > 0) {
                        mMenuContainer.setTranslationY(offset);
                    } else {
                        mMenuContainer.setTranslationY(-menuSize);
                    }

                } else {
                    mMenuContainer.offsetTopAndBottom(offset - mMenuContainer.getTop());
                    mMenuContainer.setVisibility(offsetPixels == 0 ? INVISIBLE : VISIBLE);
                }
                break;
            }

            case BOTTOM: {
                if (USE_TRANSLATIONS) {
                    if (offsetPixels != 0) {
                        mMenuContainer.setTranslationY(offset);
                    } else {
                        mMenuContainer.setTranslationY(menuSize);
                    }

                } else {
                    final int oldOffset = mMenuContainer.getBottom() - height;
                    final int offsetBy = offset - oldOffset;
                    mMenuContainer.offsetTopAndBottom(offsetBy);
                    mMenuContainer.setVisibility(offsetPixels == 0 ? INVISIBLE : VISIBLE);
                }
                break;
            }
        }

    }
843023
function cleanTouchActions(actions) {
    // none
    if (inStr(actions, TOUCH_ACTION_NONE)) {
        return TOUCH_ACTION_NONE;
    }

    var hasPanX = inStr(actions, TOUCH_ACTION_PAN_X);
    var hasPanY = inStr(actions, TOUCH_ACTION_PAN_Y);

    // if both pan-x and pan-y are set (different recognizers
    // for different directions, e.g. horizontal pan but vertical swipe?)
    // we need none (as otherwise with pan-x pan-y combined none of these
    // recognizers will work, since the browser would handle all panning
    if (hasPanX && hasPanY) {
        return TOUCH_ACTION_NONE;
    }

    // pan-x OR pan-y
    if (hasPanX || hasPanY) {
        return hasPanX ? TOUCH_ACTION_PAN_X : TOUCH_ACTION_PAN_Y;
    }

    // manipulation
    if (inStr(actions, TOUCH_ACTION_MANIPULATION)) {
        return TOUCH_ACTION_MANIPULATION;
    }

    return TOUCH_ACTION_AUTO;
}
1206950
function(inPositions) {
			// the least recent touch and the most recent touch determine the bounding box of the gesture event
			var p = inPositions;
			// center the first touch as 0,0
			return {
				magnitude: p.h,
				xcenter: Math.abs(Math.round(p.fx + (p.x / 2))),
				ycenter: Math.abs(Math.round(p.fy + (p.y / 2)))
			};
		}
1127251
function(evt) {
        evt.preventDefault();
        evt.stopPropagation();
        if (debug) { timedLog("secondFinger"); }
        if (evt.touches.length < 2) {
          return;
        }
        // we need to rebind finger 1, because it may have moved!
        transform.x1 = evt.touches[0].pageX;
        transform.y1 = evt.touches[0].pageY;
        transform.x2 = evt.touches[1].pageX;
        transform.y2 = evt.touches[1].pageY;

        var x1 = transform.x1,
          y1 = transform.y1,
          x2 = transform.x2,
          y2 = transform.y2,
          dx = x2 - x1,
          dy = y2 - y1,
          d = Math.sqrt(dx*dx + dy*dy),
          a = Math.atan2(dy,dx);

        transform.distance = d;
        transform.angle = a;
      }
642589
function(time, x, y) {
		if(time - _gestureCheckSpeedTime > 50) {
			var o = _posPoints.length > 2 ? _posPoints.shift() : {};
			o.x = x;
			o.y = y; 
			_posPoints.push(o);
			_gestureCheckSpeedTime = time;
		}
	}
1083735
def ms_pan(self, viewer, event, data_x, data_y):
        
        if not self.canpan:
            return True

        x, y = viewer.get_last_win_xy()
        if event.state == 'move':
            data_x, data_y = self.get_new_pan(viewer, x, y,
                                              ptype=self._pantype)
            viewer.panset_xy(data_x, data_y)

        elif event.state == 'down':
            self.pan_set_origin(viewer, x, y, data_x, data_y)
            self.pan_start(viewer, ptype=2)

        else:
            self.pan_stop(viewer)
        return True
1110031
def pan(query, from, to, options={})
      ensure_query_class_or_nil(query)

      gesture_options = options.dup

      gesture_options[:timeout] ||= Calabash::Gestures::DEFAULT_GESTURE_WAIT_TIMEOUT

      _pan(query, from, to, gesture_options)
    end