-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathseinjs.js
78 lines (75 loc) · 2 KB
/
seinjs.js
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
"use strict";
var _injectCanvas = require("./injectCanvas");
/**
* @File : index.js
* @Author :dtysky ([email protected])
* @Date : 2019/7/25 上午11:06:59
* @Description:
*/
Component({
properties: {
width: {
type: Number,
value: 0
},
height: {
type: Number,
value: 0
},
top: {
type: Number,
value: 0
},
left: {
type: Number,
value: 0
}
},
data: {
width: 0,
height: 0,
dpi: 2
},
canvas: null,
ready: function ready() {
var _this = this;
var _wx$window = wx.window,
h = _wx$window.innerHeight,
w = _wx$window.innerWidth,
dpi = _wx$window.devicePixelRatio;
var data = {
width: this.properties.width || (isNaN(w) ? parseInt(w) : w),
height: this.properties.height || (isNaN(h) ? parseInt(h) : h),
dpi: isNaN(dpi) ? parseInt(dpi) : dpi
};
this.setData(data, function () {
const query = wx.createSelectorQuery();
query.in(this).select('#sein-canvas').fields({node: true, size: true}).exec((res) => {
const canvas = res[0].node;
_this.canvas = (0, _injectCanvas.injectCanvas)(canvas, _this.data);
_this.triggerEvent('SeinCanvasCreated', _this.canvas);
});
});
},
detached: function didUnmount() {},
methods: {
handleTouchStart: function handleTouchStart(event) {
(0, _injectCanvas.handleEvent)('touchstart', event);
},
handleTouchEnd: function handleTouchEnd(event) {
(0, _injectCanvas.handleEvent)('touchend', event);
},
handleTouchMove: function handleTouchMove(event) {
(0, _injectCanvas.handleEvent)('touchmove', event);
},
handleTouchCancel: function handleTouchCancel(event) {
(0, _injectCanvas.handleEvent)('touchcancel', event);
},
handleClick: function handleClick(event) {
(0, _injectCanvas.handleEvent)('click', event);
},
handleError: function handleError(event) {
(0, _injectCanvas.handleEvent)('error', event);
}
}
});