<!--
 * @Description: 地图上方
 * @Author: 王晓颖
 * @Date: 2020-09-18 09:10:39
 -->
<template>
  <div :class="select?'button-select':'button-no-select'" class="button" @click="change">
    <span :style="{'font-size':size+'px'}" class="button-text"><slot/>{{ name }}</span>
  </div>
</template>

<script>
export default {
  name: 'Button2',
  model: {
    prop: 'select',
    event: 'change'
  },
  props: {
    name: {
      type: String,
      default: ''
    },
    size: {
      type: String,
      default: '18'
    }, // 文字大小
    select: {
      type: Boolean,
      required: true
    }// 选择状态
  },
  methods: {
    change() {
      console.log('button2 click')
      // 选中则通知上级，二次点击不予处理
      // if (this.select) {
      this.$emit('click')
      // }
    }
  }
}
</script>

<style rel="stylesheet/scss" lang="scss" scoped>
  .button{
    cursor: pointer;
    color: #fff;
    padding:8px 10px;
    height:36px;
    /*background: url("../../assets/images/button/button_blue.png") no-repeat;*/
    background-size: 100% 100%;
    margin-right: 5px;
    text-align: center;
  }
  .button-no-select{
    background: url("../../assets/button_images/button2_blue.png") no-repeat;
    background-size: 100% 100%;
    color:#00bdff;
  }
  @keyframes bounce {
    0%,
    7%,
    25%,
    36%,
    45%,
    50% {
      animation-timing-function: ease-out;
      transform: translate3d(0, 0, 0);
    }

    15%,
    16% {
      animation-timing-function: ease-in;
      transform: translate3d(0, -30px, 0);
    }

    30% {
      animation-timing-function: ease-in;
      transform: translate3d(0, -16px, 0);
    }

    41% {
      animation-timing-function: ease-in;
      transform: translate3d(0, -8px, 0);
    }

    47% {
      animation-timing-function: ease-in;
      transform: translate3d(0, -3px, 0);
    }
  }
  .button-select{
    background: url("../../assets/button_images/button2_yellow.png") no-repeat;
    color: #fccd14;
    background-size: 100% 100%;
    animation: bounce 2.5s 1 0s both; // keyframe bounce,持续2.5s,播放2次
    transform-origin: center bottom;
  }
  .button-text{
    font-weight: bolder;
  }
</style>
