util.js 931 字节
Newer Older
fxy060608's avatar
init v3  
fxy060608 已提交
1
import {
fxy060608's avatar
fxy060608 已提交
2 3 4 5 6 7
  ANI_SHOW,
  ANI_DURATION
} from '../../constants'

import {
  navigateFinish
fxy060608's avatar
init v3  
fxy060608 已提交
8 9
} from '../../framework/navigator'

fxy060608's avatar
fxy060608 已提交
10 11 12 13 14 15 16 17 18 19
export function showWebview (webview, animationType, animationDuration, showCallback, delay) {
  if (typeof delay === 'undefined') {
    delay = webview.nvue ? 0 : 100
  }

  if (typeof animationDuration === 'undefined') {
    animationDuration = ANI_DURATION
  } else {
    animationDuration = parseInt(animationDuration)
  }
fxy060608's avatar
init v3  
fxy060608 已提交
20

fxy060608's avatar
fxy060608 已提交
21 22 23
  if (process.env.NODE_ENV !== 'production') {
    console.log(`[show][${Date.now()}]`, delay)
  }
fxy060608's avatar
init v3  
fxy060608 已提交
24 25 26 27 28
  setTimeout(() => {
    webview.show(
      animationType || ANI_SHOW,
      animationDuration || ANI_DURATION,
      () => {
fxy060608's avatar
fxy060608 已提交
29 30 31
        if (process.env.NODE_ENV !== 'production') {
          console.log(`[show.callback][${Date.now()}]`)
        }
fxy060608's avatar
init v3  
fxy060608 已提交
32
        showCallback && showCallback()
fxy060608's avatar
fxy060608 已提交
33
        navigateFinish(webview)
fxy060608's avatar
init v3  
fxy060608 已提交
34 35
      }
    )
fxy060608's avatar
fxy060608 已提交
36
  }, delay)
fxy060608's avatar
init v3  
fxy060608 已提交
37
}