'use strict';

Object.defineProperty(exports, "__esModule", {
    value: true
});

var _babelHelperVueJsxMergeProps = require('babel-helper-vue-jsx-merge-props');

var _babelHelperVueJsxMergeProps2 = _interopRequireDefault(_babelHelperVueJsxMergeProps);

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }

var CarouselItem = {
    name: 'SnCarouselItem',
    props: {
        size: Number
    },

    data: function data() {
        return {
            offset: 0
        };
    },
    beforeCreate: function beforeCreate() {
        this.$parent.swipes.push(this);
    },
    destroyed: function destroyed() {
        this.$parent.swipes.splice(this.$parent.swipes.indexOf(this._self), 1);
    },
    render: function render() {
        var h = arguments[0];
        var _$parent = this.$parent,
            vertical = _$parent.vertical,
            computedWidth = _$parent.computedWidth,
            computedHeight = _$parent.computedHeight,
            activeIndicator = _$parent.activeIndicator;


        var style = {
            width: (this.size || computedWidth) + 'px',
            height: vertical ? computedHeight + 'px' : '100%',
            transform: 'translate' + (vertical ? 'Y' : 'X') + '(' + this.offset + 'px)'
        };

        return h(
            'div',
            (0, _babelHelperVueJsxMergeProps2['default'])([{
                'class': ['sn-carousel-item', activeIndicator === this.$parent.swipes.indexOf(this._self) ? 'sn-carousel-item-active' : ''],
                style: style
            }, { on: this.$listeners }]),
            [this.$slots['default']]
        );
    }
};

CarouselItem.install = function (Vue) {
    Vue.component(CarouselItem.name, CarouselItem);
};

exports['default'] = CarouselItem;
module.exports = exports.default;