chore: merge branch "dev"
This commit is contained in:
@@ -0,0 +1,16 @@
|
||||
# Changelog
|
||||
|
||||
### [v1.2.0]
|
||||
`2019-11-22`
|
||||
|
||||
- fix incorrect touchmove behaviour in Firefox [\#5118](https://github.com/youzan/vant/pull/5118)
|
||||
|
||||
### [v1.1.0]
|
||||
`2019-06-03`
|
||||
|
||||
- skip emulator when browser support touch event
|
||||
|
||||
### [v1.0.0]
|
||||
`2019-05-28`
|
||||
|
||||
- initial release
|
||||
@@ -78,34 +78,30 @@ function TouchList() {
|
||||
return touchList;
|
||||
}
|
||||
|
||||
/**
|
||||
* Simple trick to fake touch event support
|
||||
* this is enough for most libraries like Modernizr and Hammer
|
||||
*/
|
||||
function fakeTouchSupport() {
|
||||
var objs = [window, document.documentElement];
|
||||
var props = ['ontouchstart', 'ontouchmove', 'ontouchcancel', 'ontouchend'];
|
||||
|
||||
for (var o = 0; o < objs.length; o++) {
|
||||
for (var p = 0; p < props.length; p++) {
|
||||
if (objs[o] && objs[o][props[p]] === undefined) {
|
||||
objs[o][props[p]] = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* only trigger touches when the left mousebutton has been pressed
|
||||
* @param touchType
|
||||
* @returns {Function}
|
||||
*/
|
||||
|
||||
|
||||
var initiated = false;
|
||||
function onMouse(touchType) {
|
||||
return function(ev) {
|
||||
// prevent mouse events
|
||||
|
||||
if (ev.which !== 1) {
|
||||
return;
|
||||
if (ev.type === 'mousedown') {
|
||||
initiated = true;
|
||||
}
|
||||
|
||||
if (ev.type === 'mouseup') {
|
||||
initiated = false;
|
||||
}
|
||||
|
||||
if (ev.type === 'mousemove' && !initiated) {
|
||||
return
|
||||
}
|
||||
|
||||
// The EventTarget on which the touch point started when it was first placed on the surface,
|
||||
@@ -173,8 +169,6 @@ function getActiveTouches(mouseEv) {
|
||||
* TouchEmulator initializer
|
||||
*/
|
||||
function TouchEmulator() {
|
||||
fakeTouchSupport();
|
||||
|
||||
window.addEventListener('mousedown', onMouse('touchstart'), true);
|
||||
window.addEventListener('mousemove', onMouse('touchmove'), true);
|
||||
window.addEventListener('mouseup', onMouse('touchend'), true);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@vant/touch-emulator",
|
||||
"version": "1.1.0",
|
||||
"version": "1.2.0",
|
||||
"description": "Vant touch emulator",
|
||||
"main": "index.js",
|
||||
"publishConfig": {
|
||||
|
||||
Reference in New Issue
Block a user