提交 569e5e33 编写于 作者: Q qiang

fix: app-plus-nvue sync

上级 92a30c3b
......@@ -17,18 +17,18 @@ const iconChars = {
}
// 测试中发现通过动态绑定 class 来设置样式没生效,暂时这样列出来通过 style 来处理。
const iconColors = {
'success': '#09bb07',
'success': '#007aff',
'info': '#10aeff',
'warn': '#f76260',
'waiting': '#10aeff',
'safe_success': '#09bb07',
'safe_success': '#007aff',
'safe_warn': '#ffbe00',
'success_circle': '#09bb07',
'success_no_circle': '#09bb07',
'success_circle': '#007aff',
'success_no_circle': '#007aff',
'waiting_circle': '#10aeff',
'circle': '#c9c9c9',
'download': '#09bb07',
'info_circle': '#09bb07',
'download': '#007aff',
'info_circle': '#007aff',
'cancel': '#f43530',
'search': '#b2b2b2',
'clear': '#b2b2b2'
......
function getMovableArea (weex) {
const dom = weex.requireModule('dom')
return {
name: 'MovableArea',
props: {
scaleArea: {
type: Boolean,
default: false
}
},
data () {
return {
width: 0,
height: 0,
items: []
}
},
methods: {
_resize () {
this._getWH().then(() => {
this.items.forEach(function (item) {
item.componentInstance.setParent()
})
})
},
// _find (target, items = this.items) {
// var root = this.$el
// function get (node) {
// for (let i = 0; i < items.length; i++) {
// const item = items[i]
// if (node === item.componentInstance.$el) {
// return item
// }
// }
// if (node === root || node === document.body || node === document) {
// return null
// }
// return get(node.parentNode)
// }
// return get(target)
// },
_touchstart (t) {
// t.stopPropagation()
if (this.touchItem) {
this.touchItem.touchstart(t)
}
// var i = t.touches
// if (i) {
// if (i.length > 1) {
// var r = {
// x: i[1].pageX - i[0].pageX,
// y: i[1].pageY - i[0].pageY
// }
// this.pinchStartLen = calc(r)
// this.gapV = r
// if (!this.scaleArea) {
// var touch0 = this._find(i[0].target)
// var touch1 = this._find(i[1].target)
// this._scaleMovableView = touch0 && touch0 === touch1 ? touch0 : null
// }
// }
// }
},
_touchmove (t) {
t.stopPropagation()
if (this.touchItem) {
this.touchItem.touchmove(t)
}
// var n = t.touches
// if (n) {
// if (n.length > 1) {
// t.preventDefault()
// var i = {
// x: n[1].pageX - n[0].pageX,
// y: n[1].pageY - n[0].pageY
// }
// if (this.gapV.x !== null && this.pinchStartLen > 0) {
// var r = calc(i) / this.pinchStartLen
// this._updateScale(r)
// }
// this.gapV = i
// }
// }
},
_touchend (e) {
// e.stopPropagation()
if (this.touchItem) {
this.touchItem.touchend(e)
this.touchItem = null
}
// var t = e.touches
// if (!(t && t.length)) {
// if (e.changedTouches) {
// this.gapV.x = 0
// this.gapV.y = 0
// this.pinchStartLen = null
// if (this.scaleArea) {
// this.items.forEach(function (item) {
// item.componentInstance._endScale()
// })
// } else {
// if (this._scaleMovableView) {
// this._scaleMovableView.componentInstance._endScale()
// }
// }
// }
// }
},
// _updateScale (e) {
// if (e && e !== 1) {
// if (this.scaleArea) {
// this.items.forEach(function (item) {
// item.componentInstance._setScale(e)
// })
// } else {
// if (this._scaleMovableView) {
// this._scaleMovableView.componentInstance._setScale(e)
// }
// }
// }
// },
_getWH () {
return this._getComponentSize(this.$refs.el).then(({ width, height, top, left }) => {
this.width = width
this.height = height
this.top = top
this.left = left
})
},
_getComponentSize (el) {
return new Promise((resolve) => {
dom.getComponentRect(el, ({ size }) => {
resolve(size)
})
})
}
},
created () {
this.items = []
this.gapV = {
x: null,
y: null
}
this.pinchStartLen = null
},
mounted () {
// 由于weex在mounted后渲染是异步的不能确保元素渲染完成,需要延迟执行
setTimeout(() => {
this.__isMounted = true
this._resize()
}, 200)
},
render (createElement) {
const items = []
const slots = Array.isArray(this.$slots.default) ? this.$slots.default : []
slots.forEach(vnode => {
if (vnode.componentOptions && vnode.componentOptions.tag === 'movable-view') {
items.push(vnode)
}
})
this.items = items
const listeners = {}
const events = ['touchstart', 'touchmove', 'touchend']
events.forEach(event => {
listeners[event] = this[`_${event}`]
})
return createElement('div', this._g({
ref: 'el',
on: listeners,
staticClass: ['uni-movable-area']
}, this.$listeners), items, 2)
},
style: {
'uni-movable-area': {
width: '10px',
height: '10px'
}
}
}
}
export default function init (Vue, weex) {
Vue.component('movable-area', getMovableArea(weex))
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册