<template>

  <scroll-view class="left-cats" scroll-y :scroll-into-view="intoID" scroll-with-animation>
    <div
      :class="{
        'cats-item': true,
        active: cat.id === current
      }"
      v-for="(cat, index) in catL1"
      :key="cat.id"
      :id="'l' + cat.id"
      @click="handleClick(cat.id, index)"
    >
      <text class="cat-name">{{cat.name}}</text>
    </div>
  </scroll-view>
</template>

<script>
export default {
  name: 'LeftCats',
  props: {
    catL1: {
      default: []
    },
    current: {
      default: null
    }
  },
  data () {
    return {
      intoID: ''
    }
  },
  methods: {
    handleClick (id, index) {
      this.$emit('catChange', {
        id,
        index
      })
      // this.intoID = 'l' + id
    },
    scrollInToID (id) {
      this.intoID = 'l' + id
    }
  }
}
</script>

<style lang="scss">
@import './left-cats.scss';
</style>