@ray-js/rjs-for-wechat
Advanced tools
Comparing version 0.0.1 to 0.0.2
65
index.js
function query(selector, m, ctx) { | ||
return wx.createSelectorQuery().in(ctx._ctx) | ||
[m](selector) | ||
.fields({ | ||
node: true, | ||
size: true, | ||
}) | ||
return wx.createSelectorQuery().in(ctx._ctx)[m](selector); | ||
} | ||
function getCanvasById (id, ctx){ | ||
return new Promise((resolve, reject) => query(`#${id}`, 'select', ctx).exec(res => resolve(res[0]?.node))) | ||
function fields(noderef, args = { node: true, size: true }) { | ||
return noderef.fields(args); | ||
} | ||
const Render = function (args) { | ||
function fn(ctx){ | ||
this._ctx = ctx | ||
} | ||
fn.prototype = Object.create(args) | ||
return fn | ||
function getCanvasById(id, ctx) { | ||
return new Promise((resolve) => | ||
fields(query(`#${id}`, "select", ctx)).exec((res) => resolve(res[0]?.node)) | ||
); | ||
} | ||
const getSystemInfo = function(){ | ||
return wx.getSystemInfoSync() | ||
} | ||
const Render = function (args) { | ||
function fn(ctx) { | ||
this._ctx = ctx; | ||
} | ||
fn.prototype = Object.create(args); | ||
return fn; | ||
}; | ||
const getViewNodes = function(selector, ctx) { | ||
return new Promise((resolve, reject) => query(selector, 'selectAll', ctx).exec(res => resolve(res[0]))) | ||
} | ||
const getSystemInfo = function () { | ||
return wx.getSystemInfoSync(); | ||
}; | ||
const getBoundingClientRectById = function(id, ctx){ | ||
return new Promise((resolve) => query(`#${id}`, 'select', ctx).boundingClientRect(res => resolve(res)).exec()) | ||
} | ||
const getViewNodes = function (selector, ctx) { | ||
return new Promise((resolve, reject) => | ||
fields(query(selector, "selectAll", ctx)).exec((res) => resolve(res[0])) | ||
); | ||
}; | ||
const getBoundingClientRectById = function (id, ctx) { | ||
return new Promise((resolve) => | ||
query(`#${id}`, "select", ctx) | ||
.boundingClientRect((res) => resolve(res)) | ||
.exec() | ||
); | ||
}; | ||
module.exports = { | ||
Render, | ||
getCanvasById, | ||
getSystemInfo, | ||
getViewNodes, | ||
getBoundingClientRectById | ||
} | ||
Render, | ||
getCanvasById, | ||
getSystemInfo, | ||
getViewNodes, | ||
getBoundingClientRectById, | ||
}; |
{ | ||
"name": "@ray-js/rjs-for-wechat", | ||
"main": "index.js", | ||
"version": "0.0.1" | ||
} | ||
"version": "0.0.2" | ||
} |
@@ -1,1 +0,4 @@ | ||
rjs(render javascript script) 只在视图层执行的脚本 | ||
### rjs(render javascript script): | ||
A rendering script can be used to handle frequent drawing tasks and improve the animation rendering performance at the view layer. | ||
You can get more information on our official website: https://developer.tuya.com/en/miniapp/framework/api/render |
1373
40
4