var __extends = (this && this.__extends) || (function () {
    var extendStatics = Object.setPrototypeOf ||
        ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
        function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
(function (factory) {
    if (typeof module === "object" && typeof module.exports === "object") {
        var v = factory(require, exports);
        if (v !== undefined) module.exports = v;
    }
    else if (typeof define === "function" && define.amd) {
        define(["require", "exports", "./drag-gesture", "../util/util", "../util/dom"], factory);
    }
})(function (require, exports) {
    "use strict";
    Object.defineProperty(exports, "__esModule", { value: true });
    var drag_gesture_1 = require("./drag-gesture");
    var util_1 = require("../util/util");
    var dom_1 = require("../util/dom");
    var SlideGesture = (function (_super) {
        __extends(SlideGesture, _super);
        /**
         * @param {?} plt
         * @param {?} element
         * @param {?=} opts
         */
        function SlideGesture(plt, element, opts) {
            if (opts === void 0) { opts = {}; }
            var _this = _super.call(this, plt, element, opts) || this;
            _this.slide = null;
            return _this;
        }
        /**
         * @param {?} slide
         * @param {?} ev
         * @return {?}
         */
        SlideGesture.prototype.getSlideBoundaries = function (slide, ev) {
            return {
                min: 0,
                max: this.getNativeElement().offsetWidth
            };
        };
        /**
         * @param {?} slide
         * @param {?} ev
         * @return {?}
         */
        SlideGesture.prototype.getElementStartPos = function (slide, ev) {
            return 0;
        };
        /**
         * @param {?} ev
         * @return {?}
         */
        SlideGesture.prototype.onDragStart = function (ev) {
            this.onSlideBeforeStart(ev);
            var /** @type {?} */ coord = (dom_1.pointerCoord(ev));
            var /** @type {?} */ pos = coord[this.direction];
            this.slide = {
                min: 0,
                max: 0,
                pointerStartPos: pos,
                pos: pos,
                timestamp: Date.now(),
                elementStartPos: 0,
                started: true,
                delta: 0,
                distance: 0,
                velocity: 0,
            };
            // TODO: we should run this in the next frame
            var _a = this.getSlideBoundaries(this.slide, ev), min = _a.min, max = _a.max;
            this.slide.min = min;
            this.slide.max = max;
            this.slide.elementStartPos = this.getElementStartPos(this.slide, ev);
            this.onSlideStart(this.slide, ev);
        };
        /**
         * @param {?} ev
         * @return {?}
         */
        SlideGesture.prototype.onDragMove = function (ev) {
            var /** @type {?} */ slide = this.slide;
            (void 0) /* assert */;
            var /** @type {?} */ coord = (dom_1.pointerCoord(ev));
            var /** @type {?} */ newPos = coord[this.direction];
            var /** @type {?} */ newTimestamp = Date.now();
            var /** @type {?} */ velocity = (newPos - slide.pos) / (newTimestamp - slide.timestamp);
            slide.pos = newPos;
            slide.timestamp = newTimestamp;
            slide.distance = util_1.clamp(slide.min, newPos - slide.pointerStartPos + slide.elementStartPos, slide.max);
            slide.velocity = velocity;
            slide.delta = newPos - slide.pointerStartPos;
            this.onSlide(slide, ev);
        };
        /**
         * @param {?} ev
         * @return {?}
         */
        SlideGesture.prototype.onDragEnd = function (ev) {
            this.onSlideEnd(this.slide, ev);
            this.slide = null;
        };
        /**
         * @param {?=} ev
         * @return {?}
         */
        SlideGesture.prototype.onSlideBeforeStart = function (ev) { };
        /**
         * @param {?=} slide
         * @param {?=} ev
         * @return {?}
         */
        SlideGesture.prototype.onSlideStart = function (slide, ev) { };
        /**
         * @param {?=} slide
         * @param {?=} ev
         * @return {?}
         */
        SlideGesture.prototype.onSlide = function (slide, ev) { };
        /**
         * @param {?=} slide
         * @param {?=} ev
         * @return {?}
         */
        SlideGesture.prototype.onSlideEnd = function (slide, ev) { };
        return SlideGesture;
    }(drag_gesture_1.PanGesture));
    exports.SlideGesture = SlideGesture;
    function SlideGesture_tsickle_Closure_declarations() {
        /** @type {?} */
        SlideGesture.prototype.slide;
    }
});
//# sourceMappingURL=slide-gesture.js.map