<!--
 * @Author: ChenChanghua
 * @Date: 2023-03-08 14:52:17
 * @Description: file content
-->
<script setup>
import { ref } from "vue";
import { EdgeDirection } from "jsview";

const props = defineProps({
  data: Object,
  onAction: Object,
  anim: Object,
});
const bgImage = "https://cdn.release.qcast.cn/JsViewFrameworkTester/JsViewVueSampleResources/DemoForOperator/PosterAnim/Breath/Item/background.png";

const focused = ref(false);
const animation = ref(null);

// 注册回调
const onFocus = () => {
  focused.value = true;
  animation.value = `${props.anim.name} 2s infinite`;
};
const onBlur = () => {
  focused.value = false;
  animation.value = null;
};
const onClick = () => {};

props.onAction.register("onFocus", onFocus);
props.onAction.register("onBlur", onBlur);
props.onAction.register("onClick", onClick);
</script>

<template>
  <div
    :style="{
      width: data.width,
      height: data.height,
      animation: animation,
    }"
  >
    <div
      :style="{
        width: data.width,
        height: data.height,
        fontSize: 30,
        color: focused ? '#FF0000' : '#FFFFFF',
        backgroundImage: bgImage,
        lineHeight: data.height,
        textAlign: 'center',
      }"
    >
      呼吸
    </div>
  </div>
</template>
