Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 25 additions & 7 deletions src/navigation-bar/navigation-bar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,25 +54,43 @@ Component({
displayStyle: ''
},
attached() {
const isSupport = !!wx.getMenuButtonBoundingClientRect
const rect = wx.getMenuButtonBoundingClientRect ? wx.getMenuButtonBoundingClientRect() : null
wx.getSystemInfo({
success: res => {
const ios = !!(res.system.toLowerCase().search('ios') + 1)
this.setData({
ios,
statusBarHeight: res.statusBarHeight,
innerWidth: isSupport ? `width:${rect.left}px` : '',
innerPaddingRight: isSupport ? `padding-right:${res.windowWidth - rect.left}px` : '',
leftWidth: isSupport ? `width:${res.windowWidth - rect.left}px` : '',
ios: ios,
statusBarHeight: res.statusBarHeight
})
this.setStyle(res)
},
})
},
/**
* 组件的方法列表
*/
methods: {
setStyle(res) {
var isSupport = !!wx.getMenuButtonBoundingClientRect
if (isSupport) {
var rect = wx.getMenuButtonBoundingClientRect()
this.setData({
innerWidth: 'width:' + rect.left + 'px',
innerPaddingRight: 'padding-right:' + (res.windowWidth - rect.left) + 'px',
leftWidth: 'width:' + (res.windowWidth - rect.left) + 'px'
})
if (rect.left === 0) {
setTimeout(() => {
this.setStyle(res)
}, 100)
}
} else {
this.setData({
innerWidth: '',
innerPaddingRight: '',
leftWidth: ''
})
}
},
_showChange(show) {
const animated = this.data.animated
let displayStyle = ''
Expand Down