UNPKG

para-bridge-demo

Version:

a bridge api for js-ios/andriod rest

64 lines 2.1 kB
``` tsx private flag; private navbarParam: INavbarParam = { bgColor: '#ffffff', fontColor: '#ffffff', isStatusBarWhiteColor: 'true', left: { left: { type: DisplayType.Icon, value: iconWhiteBack }, right: { type: DisplayType.Text, value: '返回' }, }, center: { left: { tagName: 'center_tag_click_left', type: DisplayType.Text, value: '我的订单' }, right: { tagName: 'center_tag_click_right', type: DisplayType.Icon, value: iconWhiteArrowDown }, }, right: { left: { tagName: 'right_tag_click_left', type: DisplayType.Icon, value: iconWhiteService }, right: { tagName: 'right_tag_click_right', type: DisplayType.Icon, value: iconWhiteMessage }, }, }; private handleMove = (e) => { const scrollY = window.scrollY; const move = Math.min(scrollY * 255 / 45, 255); console.log('move: ', move); if (move === 255 && !this.flag) { this.flag = true; this.floatNavbar.invokeBind(undefined, extend({}, this.navbarParam, { opacity: String(move), bgColor: '#ffffff', fontColor: '#000000', isStatusBarWhiteColor: false, left: { left: { type: DisplayType.Icon, value: iconDarkBack } }, center: { right: { type: DisplayType.Icon, value: iconDarkArrowDown }, }, right: { left: { type: DisplayType.Icon, value: iconDarkService }, right: { type: DisplayType.Icon, value: iconDarkMessage }, }, })); } if (move < 255) { this.flag = false; this.floatNavbar.invokeBind(undefined, extend({}, this.navbarParam, { opacity: String(move), })); } } private floatNavbar: SetNavbar<INavbarResult>; public componentDidMount() { if (hasQueryString('ntv_bar_float')) { window.addEventListener('scroll', this.handleMove, false); } // 设置默认的bar颜色和字体颜色, 注意Native,只能是#666666 不能是#666 this.floatNavbar = setFloatNavbar(this.navbarParam); // 初始化绑定 this.floatNavbar.invokeBind((err, data) => { if (err) { alert(JSON.stringify(err)); } else { alert(JSON.stringify(data)); } }); } ```