提交 57721682 编写于 作者: fxy060608's avatar fxy060608

fix(v3): touches

上级 e63bf48f
...@@ -9575,7 +9575,7 @@ var serviceContext = (function () { ...@@ -9575,7 +9575,7 @@ var serviceContext = (function () {
return return
} }
if (isLaunchWebview) { // 首页 if (isLaunchWebview) { // 首页
isLaunchWebviewReady = true; // isLaunchWebviewReady = true
setPreloadWebview(plus.webview.getLaunchWebview()); setPreloadWebview(plus.webview.getLaunchWebview());
} else if (!preloadWebview) { // preloadWebview 不存在,重新加载一下 } else if (!preloadWebview) { // preloadWebview 不存在,重新加载一下
setPreloadWebview(plus.webview.getWebviewById(pageId)); setPreloadWebview(plus.webview.getWebviewById(pageId));
...@@ -9908,7 +9908,7 @@ var serviceContext = (function () { ...@@ -9908,7 +9908,7 @@ var serviceContext = (function () {
}; };
} }
function wrapperEvent(event) { function wrapperEvent (event) {
event.preventDefault = noop; event.preventDefault = noop;
event.stopPropagation = noop; event.stopPropagation = noop;
event.mp = event; event.mp = event;
...@@ -9918,7 +9918,7 @@ var serviceContext = (function () { ...@@ -9918,7 +9918,7 @@ var serviceContext = (function () {
} }
const handleVdData = { const handleVdData = {
[UI_EVENT]: function onUIEvent(vdBatchEvent, vd) { [UI_EVENT]: function onUIEvent (vdBatchEvent, vd) {
vdBatchEvent.forEach(([cid, nid, event]) => { vdBatchEvent.forEach(([cid, nid, event]) => {
nid = String(nid); nid = String(nid);
const target = vd.elements.find(target => target.cid === cid && target.nid === nid); const target = vd.elements.find(target => target.cid === cid && target.nid === nid);
...@@ -9930,14 +9930,14 @@ var serviceContext = (function () { ...@@ -9930,14 +9930,14 @@ var serviceContext = (function () {
} }
}; };
function onVdSync$1(vdBatchData, vd) { function onVdSync$1 (vdBatchData, vd) {
vdBatchData.forEach(([type, vdData]) => { vdBatchData.forEach(([type, vdData]) => {
handleVdData[type](vdData, vd); handleVdData[type](vdData, vd);
}); });
} }
class VDomSync { class VDomSync {
constructor(pageId, pagePath, pageVm) { constructor (pageId, pagePath, pageVm) {
this.pageId = pageId; this.pageId = pageId;
this.pagePath = pagePath; this.pagePath = pagePath;
this.pageVm = pageVm; this.pageVm = pageVm;
...@@ -9952,47 +9952,47 @@ var serviceContext = (function () { ...@@ -9952,47 +9952,47 @@ var serviceContext = (function () {
this._init(); this._init();
} }
_init() { _init () {
registerVdSync(this.pageId, (vdBatchData) => { registerVdSync(this.pageId, (vdBatchData) => {
onVdSync$1(vdBatchData, this); onVdSync$1(vdBatchData, this);
}); });
} }
addMountedVm(vm) { addMountedVm (vm) {
vm._$mounted(); // 触发vd数据同步 vm._$mounted(); // 触发vd数据同步
this.addVdSyncCallback(function mounted() { this.addVdSyncCallback(function mounted () {
vm.__call_hook('mounted'); vm.__call_hook('mounted');
}); });
} }
addUpdatedVm(vm) { addUpdatedVm (vm) {
vm._$updated(); // 触发vd数据同步 vm._$updated(); // 触发vd数据同步
this.addVdSyncCallback(function mounted() { this.addVdSyncCallback(function mounted () {
vm.__call_hook('updated'); vm.__call_hook('updated');
}); });
} }
addVdSyncCallback(callback) { addVdSyncCallback (callback) {
isFn(callback) && vdSyncCallbacks.push(callback); isFn(callback) && vdSyncCallbacks.push(callback);
} }
getVm(id) { getVm (id) {
return this.vms[id] return this.vms[id]
} }
addVm(vm) { addVm (vm) {
this.vms[vm._$id] = vm; this.vms[vm._$id] = vm;
} }
removeVm(vm) { removeVm (vm) {
delete this.vms[vm._$id]; delete this.vms[vm._$id];
} }
addElement(elm) { addElement (elm) {
this.elements.indexOf(elm) === -1 && this.elements.push(elm); this.elements.indexOf(elm) === -1 && this.elements.push(elm);
} }
removeElement(elm) { removeElement (elm) {
const elmIndex = this.elements.indexOf(elm); const elmIndex = this.elements.indexOf(elm);
if (elmIndex === -1) { if (elmIndex === -1) {
return console.error(`removeElement[${elm.cid}][${elm.nid}] not found`) return console.error(`removeElement[${elm.cid}][${elm.nid}] not found`)
...@@ -10000,11 +10000,11 @@ var serviceContext = (function () { ...@@ -10000,11 +10000,11 @@ var serviceContext = (function () {
this.elements.splice(elmIndex, 1); this.elements.splice(elmIndex, 1);
} }
push(type, cid, data) { push (type, cid, data) {
this.batchData.push([type, [cid, data]]); this.batchData.push([type, [cid, data]]);
} }
sendPageCreate(data) { sendPageCreate (data) {
this.pageCreateData = data; this.pageCreateData = data;
UniServiceJSBridge.publishHandler(VD_SYNC, { UniServiceJSBridge.publishHandler(VD_SYNC, {
data: [ data: [
...@@ -10016,7 +10016,7 @@ var serviceContext = (function () { ...@@ -10016,7 +10016,7 @@ var serviceContext = (function () {
}, [this.pageId]); }, [this.pageId]);
} }
flush() { flush () {
if (!this.initialized) { if (!this.initialized) {
this.initialized = true; this.initialized = true;
this.batchData.push([PAGE_CREATED, [this.pageId, this.pagePath]]); this.batchData.push([PAGE_CREATED, [this.pageId, this.pagePath]]);
...@@ -10032,26 +10032,26 @@ var serviceContext = (function () { ...@@ -10032,26 +10032,26 @@ var serviceContext = (function () {
} }
} }
restorePageCreate() { restorePageCreate () {
this.batchData.push([PAGE_CREATE, this.pageCreateData]); this.batchData.push([PAGE_CREATE, this.pageCreateData]);
} }
restoreMountedData() { restoreMountedData () {
const addMountedData = (vm) => { const addMountedData = (vm) => {
if (vm._$id) { if (vm._$id) {
this.push(MOUNTED_DATA, vm._$id, vm._$data); this.push(MOUNTED_DATA, vm._$id, vm._$data);
} }
// vue 中 $children 顺序不可靠,可能存在恢复误差 // TODO vue 中 $children 顺序不可靠,可能存在恢复误差
vm.$children.forEach(childVm => addMountedData(childVm)); vm.$children.forEach(childVm => addMountedData(childVm));
}; };
addMountedData(this.pageVm); addMountedData(this.pageVm);
} }
restorePageCreated() { restorePageCreated () {
this.batchData.push([PAGE_CREATED, [this.pageId, this.pagePath]]); this.batchData.push([PAGE_CREATED, [this.pageId, this.pagePath]]);
} }
restore() { restore () {
this.initialized = true; this.initialized = true;
this.batchData.length = 0; this.batchData.length = 0;
...@@ -10062,7 +10062,7 @@ var serviceContext = (function () { ...@@ -10062,7 +10062,7 @@ var serviceContext = (function () {
this.flush(); this.flush();
} }
destroy() { destroy () {
this.batchData.length = 0; this.batchData.length = 0;
this.vms = Object.create(null); this.vms = Object.create(null);
this.initialized = false; this.initialized = false;
......
...@@ -1391,3 +1391,12 @@ uni-video[hidden] { ...@@ -1391,3 +1391,12 @@ uni-video[hidden] {
pointer-events: none; pointer-events: none;
} }
uni-web-view {
position: absolute;
left: 0;
right: 0;
top: 0;
bottom: 0;
}
...@@ -125,11 +125,9 @@ function touchstart (evt) { ...@@ -125,11 +125,9 @@ function touchstart (evt) {
return return
} }
const { const {
touches: [{ pageX,
pageX, pageY
pageY } = evt.touches[0]
}]
} = evt
startPageX = pageX startPageX = pageX
startPageY = pageY startPageY = pageY
......
...@@ -20,7 +20,7 @@ import { ...@@ -20,7 +20,7 @@ import {
vdSyncCallbacks vdSyncCallbacks
} from '../subscribe-handlers/on-vd-sync-callback' } from '../subscribe-handlers/on-vd-sync-callback'
function wrapperEvent(event) { function wrapperEvent (event) {
event.preventDefault = noop event.preventDefault = noop
event.stopPropagation = noop event.stopPropagation = noop
event.mp = event event.mp = event
...@@ -30,7 +30,7 @@ function wrapperEvent(event) { ...@@ -30,7 +30,7 @@ function wrapperEvent(event) {
} }
const handleVdData = { const handleVdData = {
[UI_EVENT]: function onUIEvent(vdBatchEvent, vd) { [UI_EVENT]: function onUIEvent (vdBatchEvent, vd) {
vdBatchEvent.forEach(([cid, nid, event]) => { vdBatchEvent.forEach(([cid, nid, event]) => {
nid = String(nid) nid = String(nid)
const target = vd.elements.find(target => target.cid === cid && target.nid === nid) const target = vd.elements.find(target => target.cid === cid && target.nid === nid)
...@@ -42,14 +42,14 @@ const handleVdData = { ...@@ -42,14 +42,14 @@ const handleVdData = {
} }
} }
function onVdSync(vdBatchData, vd) { function onVdSync (vdBatchData, vd) {
vdBatchData.forEach(([type, vdData]) => { vdBatchData.forEach(([type, vdData]) => {
handleVdData[type](vdData, vd) handleVdData[type](vdData, vd)
}) })
} }
export class VDomSync { export class VDomSync {
constructor(pageId, pagePath, pageVm) { constructor (pageId, pagePath, pageVm) {
this.pageId = pageId this.pageId = pageId
this.pagePath = pagePath this.pagePath = pagePath
this.pageVm = pageVm this.pageVm = pageVm
...@@ -64,47 +64,47 @@ export class VDomSync { ...@@ -64,47 +64,47 @@ export class VDomSync {
this._init() this._init()
} }
_init() { _init () {
registerVdSync(this.pageId, (vdBatchData) => { registerVdSync(this.pageId, (vdBatchData) => {
onVdSync(vdBatchData, this) onVdSync(vdBatchData, this)
}) })
} }
addMountedVm(vm) { addMountedVm (vm) {
vm._$mounted() // 触发vd数据同步 vm._$mounted() // 触发vd数据同步
this.addVdSyncCallback(function mounted() { this.addVdSyncCallback(function mounted () {
vm.__call_hook('mounted') vm.__call_hook('mounted')
}) })
} }
addUpdatedVm(vm) { addUpdatedVm (vm) {
vm._$updated() // 触发vd数据同步 vm._$updated() // 触发vd数据同步
this.addVdSyncCallback(function mounted() { this.addVdSyncCallback(function mounted () {
vm.__call_hook('updated') vm.__call_hook('updated')
}) })
} }
addVdSyncCallback(callback) { addVdSyncCallback (callback) {
isFn(callback) && vdSyncCallbacks.push(callback) isFn(callback) && vdSyncCallbacks.push(callback)
} }
getVm(id) { getVm (id) {
return this.vms[id] return this.vms[id]
} }
addVm(vm) { addVm (vm) {
this.vms[vm._$id] = vm this.vms[vm._$id] = vm
} }
removeVm(vm) { removeVm (vm) {
delete this.vms[vm._$id] delete this.vms[vm._$id]
} }
addElement(elm) { addElement (elm) {
this.elements.indexOf(elm) === -1 && this.elements.push(elm) this.elements.indexOf(elm) === -1 && this.elements.push(elm)
} }
removeElement(elm) { removeElement (elm) {
const elmIndex = this.elements.indexOf(elm) const elmIndex = this.elements.indexOf(elm)
if (elmIndex === -1) { if (elmIndex === -1) {
return console.error(`removeElement[${elm.cid}][${elm.nid}] not found`) return console.error(`removeElement[${elm.cid}][${elm.nid}] not found`)
...@@ -112,11 +112,11 @@ export class VDomSync { ...@@ -112,11 +112,11 @@ export class VDomSync {
this.elements.splice(elmIndex, 1) this.elements.splice(elmIndex, 1)
} }
push(type, cid, data) { push (type, cid, data) {
this.batchData.push([type, [cid, data]]) this.batchData.push([type, [cid, data]])
} }
sendPageCreate(data) { sendPageCreate (data) {
this.pageCreateData = data this.pageCreateData = data
UniServiceJSBridge.publishHandler(VD_SYNC, { UniServiceJSBridge.publishHandler(VD_SYNC, {
data: [ data: [
...@@ -128,7 +128,7 @@ export class VDomSync { ...@@ -128,7 +128,7 @@ export class VDomSync {
}, [this.pageId]) }, [this.pageId])
} }
flush() { flush () {
if (!this.initialized) { if (!this.initialized) {
this.initialized = true this.initialized = true
this.batchData.push([PAGE_CREATED, [this.pageId, this.pagePath]]) this.batchData.push([PAGE_CREATED, [this.pageId, this.pagePath]])
...@@ -144,26 +144,26 @@ export class VDomSync { ...@@ -144,26 +144,26 @@ export class VDomSync {
} }
} }
restorePageCreate() { restorePageCreate () {
this.batchData.push([PAGE_CREATE, this.pageCreateData]) this.batchData.push([PAGE_CREATE, this.pageCreateData])
} }
restoreMountedData() { restoreMountedData () {
const addMountedData = (vm) => { const addMountedData = (vm) => {
if (vm._$id) { if (vm._$id) {
this.push(MOUNTED_DATA, vm._$id, vm._$data) this.push(MOUNTED_DATA, vm._$id, vm._$data)
} }
// vue 中 $children 顺序不可靠,可能存在恢复误差 // TODO vue 中 $children 顺序不可靠,可能存在恢复误差
vm.$children.forEach(childVm => addMountedData(childVm)) vm.$children.forEach(childVm => addMountedData(childVm))
} }
addMountedData(this.pageVm) addMountedData(this.pageVm)
} }
restorePageCreated() { restorePageCreated () {
this.batchData.push([PAGE_CREATED, [this.pageId, this.pagePath]]) this.batchData.push([PAGE_CREATED, [this.pageId, this.pagePath]])
} }
restore() { restore () {
this.initialized = true this.initialized = true
this.batchData.length = 0 this.batchData.length = 0
...@@ -174,7 +174,7 @@ export class VDomSync { ...@@ -174,7 +174,7 @@ export class VDomSync {
this.flush() this.flush()
} }
destroy() { destroy () {
this.batchData.length = 0 this.batchData.length = 0
this.vms = Object.create(null) this.vms = Object.create(null)
this.initialized = false this.initialized = false
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册