import {SlideGesture} from './slide-gesture';
import * as util from '../../util';

export class SlideEdgeGesture extends SlideGesture {
  constructor(element: Element, opts: Object = {}) {
    util.defaults(opts, {
      edge: 'left',
      threshold: 50
    });
    // Can check corners through use of eg 'left top'
    this.edges = opts.edge.split(' ');
    this.threshold = opts.threshold;
    super(element, opts);
  }

  canStart(ev) {
    this._containerRect = this.getContainerDimensions();
    return this.edges.every(edge => this._checkEdge(edge, ev.center));
  }

  getContainerDimensions() {
    return {
      left: 0,
      top: 0,
      width: window.innerWidth,
      height: window.innerHeight
    };
  }

  _checkEdge(edge, pos) {
    if ((edge === 'left' && pos.x > this._containerRect.left + this.threshold) ||
        (edge === 'right' && pos.x < this._containerRect.width - this.threshold) ||
        (edge === 'top' && pos.y > this._containerRect.top + this.threshold) ||
        (edge === 'bottom' && pos.y < this._containerRect.height - this.threshold)) {
      return false;
    }
    return true;
  }

}

@@ -749,39 +749,57 @@
     
-if ((edge === 'left' &&
+switch(edge) %7B%0A      case 'left': return
  pos.x 
-%3E
+%3C=
  thi
@@ -840,49 +840,45 @@
 hold
-) %7C%7C
+;
 %0A      
-  (edge === 'right' &&
+case 'right': return
  pos.x 
-%3C
+%3E=
  thi
@@ -920,47 +920,43 @@
 hold
-) %7C%7C
+;
 %0A      
-  (edge === 'top' &&
+case 'top': return
  pos.y 
-%3E
+%3C=
  thi
@@ -996,30 +996,20 @@
 hold
-) %7C%7C
+;
 %0A      
-  (edge ===
+case
  'bo
@@ -1017,19 +1017,25 @@
 tom'
- &&
+: return
  pos.y 
-%3C
+%3E=
  thi
@@ -1078,55 +1078,15 @@
 hold
-)) %7B%0A      return false;%0A    %7D%0A    return true;
+;%0A    %7D
 %0A  %7D

use switch statement