-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathindex.html
95 lines (95 loc) · 4.1 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>HotZone</title>
<!-- import reset.css -->
<link rel="stylesheet" href="https://unpkg.com/ress/dist/ress.min.css">
<!-- import hotzone.css -->
<link rel="stylesheet" href="./dist/hotzone.min.css">
<style>
background {
background-color: #f4f4f4;
}
#box {
margin: 40px;
}
</style>
</head>
<body>
<div id="box"></div>
<!-- import RegularJS -->
<script src="https://unpkg.com/[email protected]/dist/regular.min.js"></script>
<!-- import Clipboard: only if config.showCopy === true -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/clipboard.js/1.7.1/clipboard.min.js"></script>
<!-- <script src="https://cdn.jsdelivr.net/npm/clipboard@1/dist/clipboard.min.js"></script> -->
<!-- <script src="https://cdn.rawgit.com/zenorocha/clipboard.js/v1.7.1/dist/clipboard.min.js"></script> -->
<!-- import the hotZone component -->
<script src="./dist/hotzone.min.js"></script>
<!-- usage -->
<script>
var Page = Regular.extend({
template: `<HotZone
image={image}
zones={zones}
config={config}
isEdit={isEdit}
on-add={this.add($event)}
on-erase={this.erase($event)}
on-change={this.change($event)}
on-remove={this.remove($event)}
on-overRange={this.overRange($event)}
on-copyError={this.copyError($event)}
on-copySuccess={this.copySuccess($event)}
></HotZone>`,
config: function(data) {
Object.assign(data, {
image: 'http://haitao.nos.netease.com/EbrC2L4UuXFI1CPmWall%20o207T1705221905_1920_1080.jpg',
zones: [
{
topPer: 0.3076, // 顶部距离
leftPer: 0.1777, // 左边距离
widthPer: 0.1521, // 热区宽度
heightPer: 0.3559, // 热区高度
link: "http://www.kaola.com", // 热区链接
target: 1 // 跳转方式,0 - 当前页面打开,1 - 新页面打开
}
],
config: {
maxNum: 20, // 最多支持的热区数量
showCopy: true, // 是否显示复制按钮(init: false),为 true 时需要同时引入 clipboard
pattern: '' // 链接的正则校验规则
},
isEdit: true // 是否显示编辑态
});
this.supr(data);
},
add: function(zone) {
console.log('成功添加热区:', zone);
},
erase: function(index) {
console.log('拖拽生成的区域小于设定的边界值,不生成该区域:', index);
},
change: function(zones) {
console.log('热区发生变化:', zones);
},
remove: function(index) {
console.log('成功删除热区:', index);
},
overRange: function(index) {
console.log('达到最大热区数量:', index);
},
copyError: function(e) {
console.log('复制失败', e);
},
copySuccess: function(text) {
console.log('成功复制到剪切板:', text);
},
});
Page.component('HotZone', regularHotZone);
new Page({data: {}}).$inject(document.getElementById('box'));
</script>
</body>
</html>