Skip to content

Commit

Permalink
flx:h5 __page injection& pull translate3d
Browse files Browse the repository at this point in the history
  • Loading branch information
LengYXin authored and Chen-jj committed Aug 20, 2020
1 parent 39ed72a commit 315014f
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Component, Prop, h, ComponentInterface, Host, State, Event, EventEmitte
import classNames from 'classnames'
const Taro = require('@tarojs/taro')

function setTransform (nodeStyle, value) {
function setTransform(nodeStyle, value) {
nodeStyle.transform = value
nodeStyle.webkitTransform = value
nodeStyle.MozTransform = value
Expand All @@ -21,12 +21,12 @@ const INDICATOR = {
let supportsPassive = false
try {
const opts = Object.defineProperty({}, 'passive', {
get () {
get() {
supportsPassive = true
}
})
window.addEventListener('cancel', () => ({}), opts)
} catch (e) {}
} catch (e) { }

const willPreventDefault = supportsPassive ? { passive: false } : false

Expand Down Expand Up @@ -59,7 +59,7 @@ export class PullToRefresh implements ComponentInterface {
private scrollContainer = document.querySelector('.taro-tabbar__panel') || document.body

@Watch('currSt')
statusChange () {
statusChange() {
if (this.currSt === 'release') {
const pageEl: any = this.el.closest('.taro_page')
if (pageEl && pageEl.__page) {
Expand All @@ -68,11 +68,11 @@ export class PullToRefresh implements ComponentInterface {
}
}

componentDidUnload () {
componentDidUnload() {
this.destroy()
}

componentDidLoad () {
componentDidLoad() {
this.init()
this._isMounted = true
Taro.eventCenter.on('__taroStartPullDownRefresh', ({ successHandler, errorHandler }) => {
Expand Down Expand Up @@ -239,11 +239,16 @@ export class PullToRefresh implements ComponentInterface {
setContentStyle = (ty: number) => {
// todos: Why sometimes do not have `this.contentRef` ?
if (this.contentRef) {
setTransform(this.contentRef.style, `translate3d(0px,${ty}px,0)`)
// translate3d 不清理 会影响内部元素 定位
if (ty) {
setTransform(this.contentRef.style, `translate3d(0px,${ty}px,0)`)
}else{
setTransform(this.contentRef.style, ``)
}
}
}

render () {
render() {
const renderRefresh = (cls: string) => {
const { currSt, dragOnEdge, prefixCls } = this
const cla = classNames(cls, !dragOnEdge && `${prefixCls}-transition`)
Expand Down
2 changes: 1 addition & 1 deletion packages/taro-router/src/router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ function unloadPage (page: PageInstance | null) {
}
}

function pageOnReady (pageEl: Element | null, page: PageInstance, onLoad = false) {
function pageOnReady (pageEl: Element | null, page: PageInstance, onLoad = true) {
if (pageEl && !pageEl?.['__isReady']) {
const el = pageEl.firstElementChild
// eslint-disable-next-line no-unused-expressions
Expand Down

0 comments on commit 315014f

Please sign in to comment.