--- package/src/index.ts (excerpt) ---
import { Canvas } from '@antv/f-engine';
function convertTouches(touches) {
if (!touches) return touches;
touches.forEach((touch) => {
touch.clientX = touch.x;
touch.clientY = touch.y;
});
return touches;
}
function dispatchEvent(el, event, type) {
if (!el || !event) return;
if (!event.preventDefault) {
event.preventDefault = function() {};
}
event.type = type;
event.target = el;
const { touches, changedTouches, detail } = event;
event.touches = convertTouches(touches);
event.changedTouches = convertTouches(changedTouches);
if (detail) {
event.clientX = detail.x;
event.clientY = detail.y;
}
el.dispatchEvent(event);
}
Component({
/**
* 组件的属性列表
*/
properties: {
theme: {
type: Object,
value: {},
},
onRender: {
type: null,
value: () => {},
},
},
/**
* 组件的初始数据
*/
data: {},
ready() {
const query = wx.createSelectorQuery().in(this);
query
.select('.f-canvas')
.fields({
node: true,
size: true,
})
.exec((res) => {
const { node, width, height } = res[0];
const { requestAnimationFrame, cancelAnimationFrame } = node;
const context = node.getContext('2d');
const pixelRatio = wx.getSystemInfoSync().pixelRatio;
// 高清设置
node.width = width * pixelRatio;
node.height = height * pixelRatio;
const { theme } = this.data;
const children = this.data.onRender(this.
--- package/lib/index.js (excerpt) ---
"use strict";
var _fEngine = require("@antv/f-engine");
function convertTouches(touches) {
if (!touches) return touches;
touches.forEach(function (touch) {
touch.clientX = touch.x;
touch.clientY = touch.y;
});
return touches;
}
function dispatchEvent(el, event, type) {
if (!el || !event) return;
if (!event.preventDefault) {
event.preventDefault = function () {};
}
event.type = type;
event.target = el;
var touches = event.touches,
changedTouches = event.changedTouches,
detail = event.detail;
event.touches = convertTouches(touches);
event.changedTouches = convertTouches(changedTouches);
if (detail) {
event.clientX = detail.x;
event.clientY = detail.y;
}
el.dispatchEvent(event);
}
Component({
/**
* 组件的属性列表
*/
properties: {
theme: {
type: Object,
value: {}
},
onRender: {
type: null,
value: function value() {}
}
},
/**
* 组件的初始数据
*/
data: {},
ready: function ready() {
var _this = this;
var query = wx.createSelectorQuery().in(this);
query.select('.f-canvas').fields({
node: true,
size: true
}).exec(function (res) {
var _a = res[0],
node = _a.node,
width = _a.width,
height = _a.height;
var requestAnimationFrame = node.requestAnimationFrame,
cancelAnimationFrame = node.cancelAnimationFrame;
var context = node.getContext('2d');
var pixelRatio = wx.getSystemInfoSync().pixelRatio;
--- package/es/index.js (excerpt) ---
import { Canvas } from '@antv/f-engine';
function convertTouches(touches) {
if (!touches) return touches;
touches.forEach(function (touch) {
touch.clientX = touch.x;
touch.clientY = touch.y;
});
return touches;
}
function dispatchEvent(el, event, type) {
if (!el || !event) return;
if (!event.preventDefault) {
event.preventDefault = function () {};
}
event.type = type;
event.target = el;
var touches = event.touches,
changedTouches = event.changedTouches,
detail = event.detail;
event.touches = convertTouches(touches);
event.changedTouches = convertTouches(changedTouches);
if (detail) {
event.clientX = detail.x;
event.clientY = detail.y;
}
el.dispatchEvent(event);
}
Component({
/**
* 组件的属性列表
*/
properties: {
theme: {
type: Object,
value: {}
},
onRender: {
type: null,
value: function value() {}
}
},
/**
* 组件的初始数据
*/
data: {},
ready: function ready() {
var _this = this;
var query = wx.createSelectorQuery().in(this);
query.select('.f-canvas').fields({
node: true,
size: true
}).exec(function (res) {
var _a = res[0],
node = _a.node,
width = _a.width,
height = _a.height;
var requestAnimationFrame = node.requestAnimationFrame,
cancelAnimationFrame = node.cancelAnimationFrame;
var context = node.getContext('2d');
var pixelRatio = wx.getSystemInfoSync().pixelRatio;
// 高清设置
import { Canvas } from '@antv/f-engine';
function convertTouches(touches) {
if (!touches) return touches;
touches.forEach((touch) => {
touch.clientX = touch.x;
touch.clientY = touch.y;
});
return touches;
}
function dispatchEvent(el, event, type) {
if (!el || !event) return;
if (!event.preventDefault) {
event.preventDefault = function() {};
}
event.type = type;
event.target = el;
const { touches, changedTouches, detail } = event;
event.touches = convertTouches(touches);
event.changedTouches = convertTouches(changedTouches);
if (detail) {
event.clientX = detail.x;
event.clientY = detail.y;
}
el.dispatchEvent(event);
}
Component({
/**
* 组件的属性列表
*/
properties: {
theme: {
type: Object,
value: {},
},
onRender: {
type: null,
value: () => {},
},
},
/**
* 组件的初始数据
*/
data: {},
ready() {
const query = wx.createSelectorQuery().in(this);
query
.select('.f-canvas')
.fields({
node: true,
size: true,
})
.exec((res) => {
const { node, width, height } = res[0];
const { requestAnimationFrame, cancelAnimationFrame } = node;
const context = node.getContext('2d');
const pixelRatio = wx.getSystemInfoSync().pixelRatio;
// 高清设置
node.width = width * pixelRatio;
node.height = height * pixelRatio;
const { theme } = this.data;
const children = this.data.onRender(this.
"use strict";
var _fEngine = require("@antv/f-engine");
function convertTouches(touches) {
if (!touches) return touches;
touches.forEach(function (touch) {
touch.clientX = touch.x;
touch.clientY = touch.y;
});
return touches;
}
function dispatchEvent(el, event, type) {
if (!el || !event) return;
if (!event.preventDefault) {
event.preventDefault = function () {};
}
event.type = type;
event.target = el;
var touches = event.touches,
changedTouches = event.changedTouches,
detail = event.detail;
event.touches = convertTouches(touches);
event.changedTouches = convertTouches(changedTouches);
if (detail) {
event.clientX = detail.x;
event.clientY = detail.y;
}
el.dispatchEvent(event);
}
Component({
/**
* 组件的属性列表
*/
properties: {
theme: {
type: Object,
value: {}
},
onRender: {
type: null,
value: function value() {}
}
},
/**
* 组件的初始数据
*/
data: {},
ready: function ready() {
var _this = this;
var query = wx.createSelectorQuery().in(this);
query.select('.f-canvas').fields({
node: true,
size: true
}).exec(function (res) {
var _a = res[0],
node = _a.node,
width = _a.width,
height = _a.height;
var requestAnimationFrame = node.requestAnimationFrame,
cancelAnimationFrame = node.cancelAnimationFrame;
var context = node.getContext('2d');
var pixelRatio = wx.getSystemInfoSync().pixelRatio;
import { Canvas } from '@antv/f-engine';
function convertTouches(touches) {
if (!touches) return touches;
touches.forEach(function (touch) {
touch.clientX = touch.x;
touch.clientY = touch.y;
});
return touches;
}
function dispatchEvent(el, event, type) {
if (!el || !event) return;
if (!event.preventDefault) {
event.preventDefault = function () {};
}
event.type = type;
event.target = el;
var touches = event.touches,
changedTouches = event.changedTouches,
detail = event.detail;
event.touches = convertTouches(touches);
event.changedTouches = convertTouches(changedTouches);
if (detail) {
event.clientX = detail.x;
event.clientY = detail.y;
}
el.dispatchEvent(event);
}
Component({
/**
* 组件的属性列表
*/
properties: {
theme: {
type: Object,
value: {}
},
onRender: {
type: null,
value: function value() {}
}
},
/**
* 组件的初始数据
*/
data: {},
ready: function ready() {
var _this = this;
var query = wx.createSelectorQuery().in(this);
query.select('.f-canvas').fields({
node: true,
size: true
}).exec(function (res) {
var _a = res[0],
node = _a.node,
width = _a.width,
height = _a.height;
var requestAnimationFrame = node.requestAnimationFrame,
cancelAnimationFrame = node.cancelAnimationFrame;
var context = node.getContext('2d');
var pixelRatio = wx.getSystemInfoSync().pixelRatio;
// 高清设置