1 Star 1 Fork 0

丶这位同学/hotspot-vue3

Create your Gitee Account
Explore and code with more than 13.5 million developers,Free private repositories !:)
Sign up
Clone or Download
contribute
Sync branch
Cancel
Notice: Creating folder will generate an empty file .keep, because not support in Git
Loading...
README
MIT

hotspot-vue3 · npm yarn github

A hot zone generation tool for VUE3 + TS projects 中文文档

image

Try out the demo!

Plug-in installation

yarn add hotspot-vue3

# or

npm install hotspot-vue3 --save

The plug-in USES

  • Introduced in the business component file
import Hotspot from "hotspot-vue3";
  • In your business code, use it as a normal component
<template>
  <div class="hotapp">
    <hotspot
      :image="image"
      :zonesInit="zones"
      :types="types"
      :minSize="52"
      :switchOptions="{
        isShowSign: true,
        isShowDelete: true,
        isOverlap: false,
        isShowActive: true
      }"
      :styleOptions="{}"
      @add="handleAdd"
    >
      <!-- <template #sign="{ zone, index }">
        {{ zone }}
        {{ index }}
      </template>
      <template #delete="{ index }">
        {{ index }}
      </template> -->
    </hotspot>
    <div class="hotapp__display">
      <button type="primary" @click="handleAdd">Add hot spots</button>
      <input
        type="text"
        v-for="(zone, index) in zones"
        :key="index"
        v-model="zone.url"
        :placeholder="`Area ${index + 1} url`"
      />
    </div>
  </div>
</template>

<script lang="ts">
import { Options, Vue } from "vue-class-component";
import Hotspot from "hotspot-vue3";

type MoreUrl = {
  [key in string | number]: string;
};
interface ZoneType {
  topPer: number;
  leftPer: number;
  widthPer: number;
  heightPer: number;
  url?: string | MoreUrl;
  active?: boolean;
  key?: string;
}

@Options({
  components: {
    Hotspot
  }
})
export default class App extends Vue {
  // image url
  image =
    "https://github.com/shadow-Fiend/readme_image/blob/master/big_fish.jpeg";
  zones = [] as ZoneType[];
  types = "move";

  handleAdd(zon: ZoneType) {
    let zone: ZoneType;
    if (zon.topPer) {
      // If this parameter exists, drag to create a hot zone
      zone = zon;
      zone.url = "https://github.com";
      this.types = "move"; // When Max hot zones exist, verify by dragging or clicking to Max
    } else {
      // Create hot zones with buttons
      zone = {
        heightPer: 0.2027, //20.27%
        leftPer: 0.2027,
        topPer: 0.2027,
        widthPer: 0.1027,
        url: "https://github.com",
        key: String(Math.random())
      } as ZoneType;
      this.types = "btn"; // When Max hot zones exist, verify by dragging or clicking to Max
    }
    this.zones.push(zone); // Hotspot data
  }
}
</script>

<style lang="scss" scoped>
.hotapp {
  font-family: Avenir, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-align: center;
  color: #2c3e50;
  margin-top: 60px;
  display: flex;
  flex-direction: column;
  align-items: center;
  min-height: 555px;
  min-width: 1000px;

  &__display {
    margin-top: 24px;

    > input {
      margin-left: 10px;
    }
  }
}
</style>

Parameters that

As shown in the sample code, import this component directly, and control all other functions through properties.

Here's what each property means:

Hotspot Attributes

Attribute Description Type Accepted Values Default
image Url address of heat base map String
zonesInit Hot zone content, in array form Array topPer、leftPer、widthPer、heightPer、url、active、key
max That is, the maximum number of displays in the current hot zone. If you do not set this parameter, it can be added indefinitely Number
types The way to add hot areas String move: Generated by dragging the mouse, btn: Generated by custom button click
switchOptions Hot zone switch properties Object isShowSign、isShowDelete、isOverlap、isShowActive
styleOptions Hot zones display some color value properties Object zoneBorderColor、zoneBgColor、zoneActiveBgColor

ZonesInit Atributes

Attribute Description Type Accepted Values Default
topPer Distance from the top as a percentage of the total area Number
leftPer Distance to the left as a percentage of the total area Number
widthPer Percentage of hot zone width in total area Number
heightPer Percentage of hot zone height to total area Number
url Hot area link address, you can define your own object to save more parameters String / any
active Hot zone activation state Boolean / undefined false / undefined
key Hot zone key, used for unique identification String Math.random()

SwitchOptions Atributes

Attribute Description Type Accepted Values Default
isShowSign Whether to display hot zone signs Boolean true
isShowDelete Whether to display the hot zone deletion sign Boolean true
isOverlap Whether coverage is allowed between hot zones Boolean false
isShowActive Click the hot zone to see if the active status is displayed Boolean true

StyleOptions Atributes

Attribute Description Type Accepted Values Default
zoneBorderColor Hot zone border color String #507bfb
zoneBgColor Hot area background color String rgba(80, 123, 251, 0.1)
zoneActiveBgColor Hot zone background color in active state. This color takes effect only when isShowActive is true String rgba(80, 123, 251, 0.4)

Write in the last

At this point, all the ways to use the plug-in are covered.

This plugin only supports vue3.x projects...

For more information about the source of the plugin, please visit the GitHub plugin repository:hotspot-vue3

MIT License Copyright (c) 2021 shadow-Fiend Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

About

A hot zone generation tool for VUE3 + TS projects expand collapse
Cancel

Releases

No release

Contributors

All

Language(Optional)

Activities

can not load any more
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
TypeScript
1
https://gitee.com/shape-of-you/hotspot-vue3.git
git@gitee.com:shape-of-you/hotspot-vue3.git
shape-of-you
hotspot-vue3
hotspot-vue3
master

Search