import { EditorModule } from "..";

export const ImgCompActions = EditorModule.action({
  handleImageHotKey(key: string) {
    if (!this.store.isEditMode) return;
    if (this.store.currComp?.compKey !== "Image") return;

    const value = this.store.currComp.value;
    if (key == "w") {
      value.y = (parseFloat(value.y) - 0.5).toFixed(2);
      return;
    }
    if (key == "s") {
      value.y = (parseFloat(value.y) + 0.5).toFixed(2);
      return;
    }
    if (key == "a") {
      value.x = (parseFloat(value.x) - 0.5).toFixed(2);
      return;
    }
    if (key == "d") {
      value.x = (parseFloat(value.x) + 0.5).toFixed(2);
      return;
    }
    if (key == "q") {
      value.s = (parseFloat(value.s) - 0.05).toFixed(2);
      return;
    }
    if (key == "e") {
      value.s = (parseFloat(value.s) + 0.05).toFixed(2);
      return;
    }
  },
});
