-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathseinjs.js
67 lines (63 loc) · 1.77 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
"use strict";
var _injectCanvas = require("./injectCanvas");
/**
* @File : index.js
* @Author :dtysky ([email protected])
* @Date : 2019/7/25 上午11:06:59
* @Description:
*/
Component({
data: {
width: 0,
height: 0,
dpi: 2,
enableNative: true
},
props: {
width: 0,
height: 0,
onSeinCanvasCreated: function onSeinCanvasCreated(canvas) {}
},
canvas: null,
didMount: function didMount() {
var _this = this;
var _my$window = my.window,
h = _my$window.innerHeight,
w = _my$window.innerWidth,
dpi = _my$window.pixelRatio;
var data = {
width: this.props.width || (isNaN(w) ? parseInt(w) : w),
height: this.props.height || (isNaN(h) ? parseInt(h) : h),
dpi: isNaN(dpi) ? parseInt(dpi) : dpi
};
this.setData(data, function () {
my._createCanvas({
id: 'canvas',
// canvas dom id
success: function success(canvas) {
_this.canvas = (0, _injectCanvas.injectCanvas)(canvas, _this.data);
_this.props.onSeinCanvasCreated(_this.canvas);
}
});
});
},
didUpdate: function didUpdate() {},
didUnmount: 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);
}
}
});