Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: imagepreview taro 增加缩放, 优化代码 #2941

Open
wants to merge 4 commits into
base: next
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 6 additions & 10 deletions src/packages/imagepreview/__test__/imagepreview.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ function sleep(delay = 0): Promise<void> {

test('basic usage test', () => {
const { container } = render(<ImagePreview images={images} visible />)

const element = container.querySelector(
'.nut-imagepreview-pop'
) as HTMLElement
Expand All @@ -59,24 +58,22 @@ test('basic usage test', () => {
test('test autoPlay', async () => {
let _container: any
act(() => {
const { container } = render(
<ImagePreview images={images} visible autoPlay={1000} />
)
const { container } = render(<ImagePreview images={images} visible />)
_container = container
})

const element = _container.querySelector(
'.nut-imagepreview-pop .nut-imagepreview-index'
) as HTMLElement
expect(element).toHaveTextContent('1')
expect(element).toHaveTextContent('1/4')

await waitFor(
async () => {
await sleep(1100)
expect(element).toHaveTextContent('2')
await sleep(4600)
expect(element).toHaveTextContent('1/4')
},
{
timeout: 2000,
timeout: 5000,
}
)
})
Expand All @@ -100,7 +97,7 @@ test('customize indicator and color', async () => {
const swiperIndicator = container.querySelector('.nut-imagepreview-swiper')
expect(swiperIndicator).toHaveAttribute(
'style',
'--nutui-indicator-color: red;'
'--nutui-indicator-color: red; --nutui-swiper-indicator-bottom: 100px;'
)
})

Expand Down Expand Up @@ -142,7 +139,6 @@ test('closeIconPosition', async () => {
closeIconPosition="bottom"
/>
)

const closeIcon = container.querySelector('.nut-imagepreview-close')
expect(closeIcon?.classList).toContain('bottom')
})
14 changes: 13 additions & 1 deletion src/packages/imagepreview/imagepreview.scss
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@
background: transparent;
color: $white;

.nut-icon {
color: $white;
}

&.top-right {
top: 50px;
right: 20px;
Expand All @@ -58,11 +62,12 @@
}

&-pop {
width: 100%;
height: 100%;
max-width: 100% !important;
background: transparent !important;
display: flex;
align-items: center;
width: 100%;
}

&-swiper {
Expand All @@ -73,6 +78,13 @@
justify-content: center;
height: 100%;

.nut-image,
.nut-video {
display: flex;
justify-content: center;
align-items: center;
}

.nut-image-preview-box {
width: 100%;
}
Expand Down
Loading
Loading