Skip to content

Commit d9c9579

Browse files
committed
fix: 修复popup层级\崩溃等问题
1 parent 350c999 commit d9c9579

11 files changed

Lines changed: 46 additions & 52 deletions

File tree

packages/nutui-taro-demo/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@
6060
"@dongdesign/inject-jd-platform-styles": "1.0.4",
6161
"@jdtaro/plugin-platform-jdhybrid": "0.2.1",
6262
"@jdtaro/taro-platform-jdharmony": "2.0.70",
63-
"@jdtaro/plugin-platform-jdharmony-cpp": "0.1.27",
63+
"@jdtaro/plugin-platform-jdharmony-cpp": "0.1.29-beta.0",
6464
"@nutui/replace-icons": "^1.0.0",
6565
"@nutui/touch-emulator": "^1.0.0",
6666
"@pmmmwh/react-refresh-webpack-plugin": "^0.5.11",

scripts/harmony/clone-jdharmony.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ const platform = args && args[0] === 'cpp' ? 'jdharmonycpp' : 'jdharmony'
1515
async function cloneJdHarmony() {
1616
// 填写coding地址
1717
const remote = 'git@coding.jd.com:DongDesign/JDHarmony.git'
18-
const branch = args && args[0] === 'cpp' ? 'feat_jdharmonycpp' : 'master'
18+
const branch = args && args[0] === 'cpp' ? 'chore_0.1.22' : 'master'
1919
const git = simpleGit({
2020
baseDir: temp,
2121
})

src/config.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,6 @@
170170
"name": "布局组件",
171171
"enName": "layout",
172172
"packages": [
173-
174173
{
175174
"version": "3.0.0",
176175
"name": "Divider",

src/packages/dialog/dialog.scss

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828
-webkit-transform: translate(-50%, -50%);
2929
transform: translate(-50%, -50%);
3030
border-radius: $dialog-border-radius;
31-
z-index: $dialog-z-index;
3231
animation-duration: 0.3s;
3332
}
3433

src/packages/dialog/dialog.taro.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import {
1717
import { useLockScrollTaro } from '@/hooks/use-lock-scoll-taro'
1818
import { mergeProps } from '@/utils/merge-props'
1919
import { defaultOverlayProps } from '@/packages/overlay/overlay.taro'
20+
import { harmony } from '@/utils/platform-taro'
2021

2122
const defaultProps: DialogBasicProps = {
2223
...defaultOverlayProps,
@@ -219,6 +220,7 @@ export const BaseDialog: FunctionComponent<Partial<DialogBasicProps>> & {
219220
}
220221

221222
const renderContent = () => {
223+
const contentZIndex = harmony() ? zIndex + 1 : zIndex // 解决harmony层级问题
222224
return (
223225
<CSSTransition
224226
in={visible}
@@ -229,7 +231,7 @@ export const BaseDialog: FunctionComponent<Partial<DialogBasicProps>> & {
229231
>
230232
<Content
231233
className={className}
232-
style={{ ...style, zIndex: zIndex + 1 }} // zIndex: zIndex + 1;解决harmony层级问题
234+
style={{ zIndex: contentZIndex, ...style }}
233235
title={title}
234236
header={header}
235237
close={renderCloseIcon()}

src/packages/overlay/demos/taro/demo3.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ const Demo3 = () => {
1515
<Cell>
1616
<View onClick={handleToggleShow}>设置动画时间</View>
1717
</Cell>
18-
1918
<Overlay
2019
visible={visible}
2120
onClick={onClose}

src/packages/overlay/overlay.scss

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,9 @@
1919
0% {
2020
opacity: 0;
2121
}
22-
2322
1% {
2423
opacity: 0;
2524
}
26-
2725
100% {
2826
opacity: 1;
2927
}
@@ -33,11 +31,9 @@
3331
0% {
3432
opacity: 1;
3533
}
36-
3734
1% {
3835
opacity: 1;
3936
}
40-
4137
100% {
4238
opacity: 0;
4339
}

src/packages/overlay/overlay.taro.tsx

Lines changed: 12 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import classNames from 'classnames'
44
import { View, ITouchEvent } from '@tarojs/components'
55
import { ComponentDefaults } from '@/utils/typings'
66
import { useLockScrollTaro } from '@/hooks/use-lock-scoll-taro'
7-
import { harmony } from '@/utils/platform-taro'
87
import { OverlayProps } from './types.taro'
98

109
export const defaultOverlayProps: OverlayProps = {
@@ -46,8 +45,8 @@ export const Overlay: FunctionComponent<
4645

4746
const classes = classNames(classPrefix, className)
4847
const styles = {
49-
...style,
5048
zIndex,
49+
...style,
5150
}
5251

5352
const handleClick = (e: ITouchEvent) => {
@@ -70,23 +69,17 @@ export const Overlay: FunctionComponent<
7069
)
7170

7271
return (
73-
<>
74-
{!harmony() ? (
75-
<CSSTransition
76-
nodeRef={nodeRef}
77-
classNames={`${classPrefix}-slide`}
78-
unmountOnExit
79-
timeout={duration}
80-
in={innerVisible}
81-
onEntered={afterShow}
82-
onExited={afterClose}
83-
>
84-
{renderOverlay()}
85-
</CSSTransition>
86-
) : (
87-
innerVisible && renderOverlay()
88-
)}
89-
</>
72+
<CSSTransition
73+
nodeRef={nodeRef}
74+
classNames={`${classPrefix}-slide`}
75+
unmountOnExit
76+
timeout={duration}
77+
in={innerVisible}
78+
onEntered={afterShow}
79+
onExited={afterClose}
80+
>
81+
{renderOverlay()}
82+
</CSSTransition>
9083
)
9184
}
9285

src/packages/popup/demos/taro/demo8.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ const Demo8 = () => {
1818
title="禁止滚动穿透"
1919
position="bottom"
2020
lockScroll
21+
onClose={() => {
22+
setScrollPenetration(false)
23+
}}
2124
>
2225
<ScrollView scrollY style={{ height: '300px' }}>
2326
{Array.from({ length: 200 })

src/packages/popup/popup.scss

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,6 @@
143143
opacity: 0;
144144
transform: scale(0.8);
145145
}
146-
147146
to {
148147
opacity: 1;
149148
transform: scale(1);
@@ -155,7 +154,6 @@
155154
opacity: 1;
156155
transform: scale(1);
157156
}
158-
159157
to {
160158
opacity: 0;
161159
transform: scale(0.8);
@@ -178,7 +176,6 @@
178176
from {
179177
opacity: 0;
180178
}
181-
182179
to {
183180
opacity: 1;
184181
}
@@ -188,7 +185,6 @@
188185
from {
189186
opacity: 1;
190187
}
191-
192188
to {
193189
opacity: 0;
194190
}
@@ -211,6 +207,9 @@
211207
from {
212208
transform: translate3d(0, -100%, 0);
213209
}
210+
to {
211+
transform: translate3d(0, 0%, 0);
212+
}
214213
}
215214

216215
@keyframes popup-slide-top-exit {
@@ -238,6 +237,9 @@
238237
from {
239238
transform: translate3d(100%, 0, 0);
240239
}
240+
to {
241+
transform: translate3d(0%, 0, 0);
242+
}
241243
}
242244

243245
@keyframes popup-slide-right-exit {
@@ -265,6 +267,9 @@
265267
from {
266268
transform: translate3d(0, 100%, 0);
267269
}
270+
to {
271+
transform: translate3d(0, 0%, 0);
272+
}
268273
}
269274

270275
@keyframes slide-bottom-exit {
@@ -292,6 +297,9 @@
292297
from {
293298
transform: translate3d(-100%, 0, 0);
294299
}
300+
to {
301+
transform: translate3d(0%, 0, 0);
302+
}
295303
}
296304

297305
@keyframes popup-slide-left-exit {

0 commit comments

Comments
 (0)