
Security News
pnpm 11.5 Adds Support for Recognizing npm Staged Publishes
pnpm 11.5 now recognizes npm staged publish approvals in release metadata, preventing those releases from being mistaken for lower-trust package publishes.
pixui-react-imageviewer
Advanced tools
在pixui页面中自适应展示大图。功能逐渐完善中,目前仅支持图片静态展示。后续将逐渐支持滑动、缩放,旋转等功能。
基于preact框架
| 属性名 | 取值 |
|---|---|
| src | 必传属性:string ,所需展示的大图的url |
| onClose | 必传属性:Function ,触发关闭时执行的回调函数 |
| backgroundStyle | 可选属性:CSSProperties ,底层背景样式,通常为全屏的半透明黑色遮罩,如不传值,则默认为{width:'100%',height:'100%',display: 'flex',flexDirection: 'row',justifyContent: 'center',alignItems: 'center',} |
| imageBoxStyle | 可选属性:CSSProperties ,当希望ImageViewer中要展示的图片有背景框时使用;如不传值,则默认没有背景框。 |
| imageAreaStyle | 可选属性:CSSProperties ,主要用于控制图片显示的大小和范围。当前图片的长或宽大于该属性所指定的大小范围时,将自适应等比例缩小到该范围内,并完整展示。 在不传入任何值的情况下,图片默认显示范围为 imageBoxStyle 大小的 80% 80%。 |
| imageStyle | 可选属性:CSSProperties,图片样式。** 注意,不可以在该样式中传入width、height等指定图片大小的属性,图片大小在组件中会根据imageArea尺寸自适应计算,在imageStyle中指定图片大小无法保证图片的自适应展示 ** |
| closeOnClickOutside | 可选属性:boolean,默认为true。点击图片以外的区域关闭imageViewer。如该属性为false,则必须自己实现关闭imageViewer的方法。 |

import { Component } from 'preact'
import { ImageViewer } from 'pixuireactcomponents';
import { Images } from './Images';
export class ImageViewerDemo extends Component<any, {
isViewerOpen: boolean;
imageUrl:string;
}> {
constructor(props) {
super(props);
this.state = {
isViewerOpen: false,
imageUrl:'',
};
}
onOpenImageViewer (url) {
console.log('onOpen');
this.setState({
isViewerOpen: true,
imageUrl:url,
})
}
onCloseImageViewer = () => {
console.log('onClose');
this.setState({
isViewerOpen: false,
})
}
render() {
return (
<div style={{
width: '100%',
height: '100%',
}}>
{/* <ImageViewer>应在root节点下才能保证全屏居中展示 */}
{this.state.isViewerOpen && <ImageViewer
src={this.state.imageUrl}
onClose={this.onCloseImageViewer}
imageAreaStyle={{
width: '80%',
height: '80%',
}}
/>}
<div style={{
backgroundColor: 'rgba(125,0,0,0.8)',
display: 'flex',
flexDirection: 'row',
justifyContent: 'center',
alignItems: 'center',
width: '50%',
height: '50%',
}}>
<img src={Images.bg1}
style={{ width: '166px', height: '102.4px' }}
onClick={()=>this.onOpenImageViewer(Images.bg1)} />
<img src={Images.bg2}
style={{ width: '166px', height: '102.4px' }}
onClick={()=>this.onOpenImageViewer(Images.bg2)} />
</div>
</div>
);
}
}
FAQs
pixui-react-imageviewer
We found that pixui-react-imageviewer demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
pnpm 11.5 now recognizes npm staged publish approvals in release metadata, preventing those releases from being mistaken for lower-trust package publishes.

Security News
Federal audit finds NIST lacked a plan to clear the NVD backlog, wasted funds on duplicate work, and delayed use of CISA data.

Research
/Security News
A mini Shai-Hulud campaign compromised Red Hat Cloud Services npm packages to steal developer and CI/CD secrets during installation.