- 更新之前 - getSelectionInformation
- 更新之后 - restoreSelection
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, { Component } from 'react'; | |
import { render } from 'react-dom'; | |
// Get the position of the mouse relative to the canvas | |
function getMousePos(canvasDom, mouseEvent) { | |
var rect = canvasDom.getBoundingClientRect(); | |
return { | |
x: mouseEvent.clientX - rect.left, | |
y: mouseEvent.clientY - rect.top | |
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Taro, { Component } from '@tarojs/taro'; | |
import { Canvas, View, Image } from '@tarojs/components'; | |
import { AtButton } from 'taro-ui'; | |
function getTouchPos(e) { | |
const rect = { | |
left: 0, | |
top: 0, | |
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* | |
* @param size 分段的大小 | |
* @param arr 需要被处理的数组 | |
*/ | |
function chunk<T>(size: number, arr: Array<T>): Array<Array<T>> { | |
return Array.from({ length: Math.ceil(arr.length / size) }, (_, i) => | |
arr.slice(i * size, i * size + size) | |
); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function check_webp_feature(feature, callback) { | |
var kTestImages = { | |
lossy: "UklGRiIAAABXRUJQVlA4IBYAAAAwAQCdASoBAAEADsD+JaQAA3AAAAAA", | |
lossless: "UklGRhoAAABXRUJQVlA4TA0AAAAvAAAAEAcQERGIiP4HAA==", | |
alpha: "UklGRkoAAABXRUJQVlA4WAoAAAAQAAAAAAAAAAAAQUxQSAwAAAARBxAR/Q9ERP8DAABWUDggGAAAABQBAJ0BKgEAAQAAAP4AAA3AAP7mtQAAAA==", | |
animation: "UklGRlIAAABXRUJQVlA4WAoAAAASAAAAAAAAAAAAQU5JTQYAAAD/////AABBTk1GJgAAAAAAAAAAAAAAAAAAAGQAAABWUDhMDQAAAC8AAAAQBxAREYiI/gcA" | |
}; | |
var img = new Image(); | |
img.onload = function () { | |
var result = (img.width > 0) && (img.height > 0); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
window.addEventListener('pointermove', event => { | |
const events = event.getCoalescedEvents(); | |
for (let event of events) { | |
const x = event.pageX; | |
const y = event.pageY; | |
// draw a line using x and y coordinates. | |
} | |
}); | |
支持esm的浏览器我们可以不polyfill,反之我们才需要polyfill。 我们构建的时候需要打两份,如果将来规则更加细化,我们可以做到更加细致。当然这个东西可以做成服务化,类似polyfill.io
- build 两次,而且只在 build 阶段做,可以用 webpack 的多配置,也可以多 webpack 实例
- mjs 格式配 babel-preset-env 的 targets.esmodules 为 true
- HTML部分
<script type="module" src="bundle.mjs"></script>
solution:
This is actually a macOS Gatekeeper issue try these steps:
To resolute Gatekeeper issues on macOS Sierra you might have to partially or completely disable Gatekeeper checks.
- Option I, For a certain application run in Terminal:
lsof -i :端口
kill -9 进程ID
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
image: node:4.2.2 | |
cache: | |
paths: | |
- node_modules/ | |
stages: | |
- test | |
test_async: |