fix: picker closing the mask flicker (#1263)

* fix: picker closing the mask flicker

* fix: picker closing the mask flicker

* chore: 本地文档站点研发

* feat: 实验性组件深色模式适配
This commit is contained in:
homi 2024-08-12 10:23:56 +08:00 committed by GitHub
parent e9ac3eab93
commit 6027a6029b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
11 changed files with 56 additions and 28 deletions

View File

@ -1,5 +1,5 @@
{
"defaultTitle": "PageContainer",
"defaultTitle": "",
"titleBarColor": "#ffffff",
"transparentTitle": "auto",
"usingComponents": {

View File

@ -5,6 +5,7 @@
.@{prefix} {
overflow: auto;
color: @COLOR_TEXT_PRIMARY;
&-safe-top {
padding-top: constant(safe-area-inset-top);
@ -22,7 +23,8 @@
top: 0;
width: 100%;
height: 100vh;
background: rgba(255, 255, 255, 0.4);
background: @COLOR_BACKGROUND;
opacity: 0.4;
z-index: 3;
}

View File

@ -40,6 +40,23 @@ Component(
},
undefined,
{
async deriveDataFromProps(nextProps) {
const [visible, duration, animation] = getValueFromProps(this, [
'visible',
'duration',
'animation',
]);
const enableAnimation = animation && duration > 0;
if (
nextProps.visible !== visible &&
enableAnimation &&
!nextProps.visible &&
!this.data.closing
) {
this.setData({ closing: true });
}
},
didUpdate(prevProps) {
const [visible, duration, animation] = getValueFromProps(this, [
'visible',
@ -47,16 +64,8 @@ Component(
'animation',
]);
const enableAnimation = animation && duration > 0;
if (prevProps.visible !== visible) {
if (enableAnimation && !visible) {
setTimeout(() => {
// 这里需要用setTimeout包一下,解决支付宝小程序Picker中导致 targetId not match
this.setData({ closing: true });
});
}
if (!enableAnimation) {
triggerEventOnly(this, visible ? 'afterShow' : 'afterClose');
}
if (prevProps.visible !== visible && !enableAnimation) {
triggerEventOnly(this, visible ? 'afterShow' : 'afterClose');
}
},
}

View File

@ -8,6 +8,7 @@
display: flex;
align-items: center;
width: fit-content;
color: @COLOR_TEXT_PRIMARY;
.@{tabsPrefix} {
&-text {
line-height: @default-line-height;

View File

@ -33,7 +33,7 @@ Component(PopupDefaultProps, {
'visible': function (nextProps) {
var visible = nextProps.visible, duration = nextProps.duration, animation = nextProps.animation;
var enableAnimation = animation && duration > 0;
if (enableAnimation && !visible) {
if (enableAnimation && !visible && !this.data.closing) {
this.setData({ closing: true });
}
if (!enableAnimation) {

View File

@ -1,10 +1,10 @@
{
/// #if WECHAT
"navigationBarTitleText": "PageContainer",
"navigationBarTitleText": "",
/// #endif
/// #if ALIPAY
"defaultTitle": "PageContainer",
"defaultTitle": "",
/// #endif
"titleBarColor": "#ffffff",

View File

@ -1,7 +1,9 @@
const { fork } = require('child_process');
const { fork,execFile } = require('child_process');
const { minidev } = require('minidev');
(async () => {
execFile('tsx', [`${process.cwd()}/scripts/dev.ts`]);
const path = require('path');
const { devServer } = await minidev.dev({
@ -22,6 +24,7 @@ const { minidev } = require('minidev');
SERVER: devServer.server,
},
});
});
devServer.on('error', (err) => {

View File

@ -5,6 +5,7 @@
.@{prefix} {
overflow: auto;
color: @COLOR_TEXT_PRIMARY;
&-safe-top {
padding-top: constant(safe-area-inset-top);
@ -22,7 +23,8 @@
top: 0;
width: 100%;
height: 100vh;
background: rgba(255, 255, 255, 0.4);
background: @COLOR_BACKGROUND;
opacity: 0.4;
z-index: 3;
}

View File

@ -41,6 +41,23 @@ Component(
undefined,
{
/// #if ALIPAY
async deriveDataFromProps(nextProps) {
const [visible, duration, animation] = getValueFromProps(this, [
'visible',
'duration',
'animation',
]);
const enableAnimation = animation && duration > 0;
if (
nextProps.visible !== visible &&
enableAnimation &&
!nextProps.visible &&
!this.data.closing
) {
this.setData({ closing: true });
}
},
didUpdate(prevProps) {
const [visible, duration, animation] = getValueFromProps(this, [
'visible',
@ -48,16 +65,8 @@ Component(
'animation',
]);
const enableAnimation = animation && duration > 0;
if (prevProps.visible !== visible) {
if (enableAnimation && !visible) {
setTimeout(() => {
// 这里需要用setTimeout包一下,解决支付宝小程序Picker中导致 targetId not match
this.setData({ closing: true });
});
}
if (!enableAnimation) {
triggerEventOnly(this, visible ? 'afterShow' : 'afterClose');
}
if (prevProps.visible !== visible && !enableAnimation) {
triggerEventOnly(this, visible ? 'afterShow' : 'afterClose');
}
},
/// #endif
@ -66,7 +75,7 @@ Component(
'visible': function (nextProps) {
const { visible, duration, animation } = nextProps;
const enableAnimation = animation && duration > 0;
if (enableAnimation && !visible) {
if (enableAnimation && !visible && !this.data.closing) {
this.setData({ closing: true });
}
if (!enableAnimation) {

View File

@ -8,6 +8,7 @@
display: flex;
align-items: center;
width: fit-content;
color: @COLOR_TEXT_PRIMARY;
.@{tabsPrefix} {
&-text {
line-height: @default-line-height;

View File

@ -1,5 +1,6 @@
import esbuild from 'esbuild';
import fs from 'fs';
// @ts-ignore
import { createInstrumenter } from 'istanbul-lib-instrument';
import os from 'os';
import path from 'path';