import { assign } from '../util/util';
import { SlideEdgeGesture } from '../gestures/slide-edge-gesture';
export class SwipeBackGesture extends SlideEdgeGesture {
    constructor(element, options, _nav, gestureCtlr) {
        super(element, assign({
            direction: 'x',
            maxEdgeStart: 75,
            gesture: gestureCtlr.create('goback-swipe', {
                priority: 20,
            })
        }, options));
        this._nav = _nav;
    }
    canStart(ev) {
        return (this._nav.canSwipeBack() &&
            super.canStart(ev));
    }
    onSlideBeforeStart(ev) {
        console.debug('swipeBack, onSlideBeforeStart', ev.type);
        this._nav.swipeBackStart();
    }
    onSlide(slide) {
        let stepValue = (slide.distance / slide.max);
        console.debug('swipeBack, onSlide, distance', slide.distance, 'max', slide.max, 'stepValue', stepValue);
        this._nav.swipeBackProgress(stepValue);
    }
    onSlideEnd(slide, ev) {
        let shouldComplete = (Math.abs(slide.velocity) > 0.2 || Math.abs(slide.delta) > Math.abs(slide.max) * 0.5);
        let currentStepValue = (slide.distance / slide.max);
        console.debug('swipeBack, onSlideEnd, shouldComplete', shouldComplete, 'currentStepValue', currentStepValue);
        this._nav.swipeBackEnd(shouldComplete, currentStepValue);
    }
}
