- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
这里我使用react-pan-zoom-svg并尝试在可缩放区域加载大型SVG
我遇到一些问题
1) 当svg
加载时,它不是从svg的中心点加载
2)当我移动SVG
时,它的矩阵值取负值
3) 无法适应屏幕
共享 jspaddel 无法正常工作,我无法解决它,但我的所有代码都在那里
请帮忙
提前谢谢
const {ReactSVGPanZoom} = window.ReactSVGPanZoom;
class Example extends React.Component{
render () {
return (
<ReactSVGPanZoom
width={window.innerWidth - 20} height={window.innerHeight - 20} scaleFactorMin={0.99}
onClick={event => console.log(event.x, event.y, event.originalEvent)}>
<svg width={4970} height={6480}>
<rect x="0" fill="#000003" stroke="#FF0000" strokeWidth="0.216" strokeMiterlimit="22.9256" width="4969.988" height="6480"/>
<g id="Layer_9">
<path id="M4_x5F_36" fill="none" stroke="#B21436" strokeWidth="1.5" strokeMiterlimit="10" d="M3696.251,4110.594v101.864"/>
<path id="M4_x5F_35" fill="none" stroke="#B21436" strokeWidth="1.5" strokeMiterlimit="10" d="M3696.251,3916.625v193.969"/>
<path id="M4_x5F_34" fill="none" stroke="#B21436" strokeWidth="1.5" strokeMiterlimit="10" d="M3696.251,3802.334v114.291"/>
<path id="M4_x5F_33" fill="none" stroke="#B21436" strokeWidth="1.5" strokeMiterlimit="10" d="M3696.251,3721.333v81.001"/>
<path id="M4_x5F_32" fill="none" stroke="#B21436" strokeWidth="1.5" strokeMiterlimit="10" d="M3696.251,3519.798v201.535"/>
<path id="M4_x5F_31" fill="none" stroke="#B21436" strokeWidth="1.5" strokeMiterlimit="10" d="M3498.39,3321.937l197.86,197.861 "/>
<path id="M4_x5F_30" fill="none" stroke="#B21436" strokeWidth="1.5" strokeMiterlimit="10" d="M3392.493,3216.04 l105.897,105.896"/>
<path id="M4_x5F_29" fill="none" stroke="#B21436" strokeWidth="1.5" strokeMiterlimit="10" d="M3392.493,3216.04l-43.478-43.478 "/>
<path id="M4_x5F_28" fill="none" stroke="#B21436" strokeWidth="1.5" strokeMiterlimit="10" d="M3253.389,3076.938l95.626,95.625 "/>
<path id="M4_x5F_27" fill="none" stroke="#B21436" strokeWidth="1.5" strokeMiterlimit="10" d="M3188.253,3011.8l65.137,65.137"/>
<path id="M4_x5F_26" fill="none" stroke="#B21436" strokeWidth="1.5" strokeMiterlimit="10" d="M3188.253,3011.8l-75.824-75.824"/>
<path id="M4_x5F_25" fill="none" stroke="#B21436" strokeWidth="1.5" strokeMiterlimit="10" d="M2994.472,2818.021 l117.956,117.956"/>
<path id="M4_x5F_24" fill="none" stroke="#B21436" strokeWidth="1.5" strokeMiterlimit="10" d="M2994.472,2818.021 l-48.396-48.396V2720.5"/>
<path id="M4_x5F_23" fill="none" stroke="#B21436" strokeWidth="1.5" strokeMiterlimit="10" d="M2946.076,2531.275V2720.5"/>
<path id="M4_x5F_22" fill="none" stroke="#B21436" strokeWidth="1.5" strokeMiterlimit="10" d="M2805.869,2531.275h140.207"/>
<path id="M4_x5F_21" fill="none" stroke="#B21436" strokeWidth="1.5" strokeMiterlimit="10" d="M2699.912,2542.543l11.269-11.268 h94.688"/>
<path id="M4_x5F_20" fill="none" stroke="#B21436" strokeWidth="1.5" strokeMiterlimit="10" d="M2645.904,2596.551l54.008-54.008 "/>
<path id="M4_x5F_19" fill="none" stroke="#B21436" strokeWidth="1.5" strokeMiterlimit="10" d="M2561.827,2596.551h84.077"/>
<path id="M4_x5F_18" fill="none" stroke="#B21436" strokeWidth="1.5" strokeMiterlimit="10" d="M2481.671,2596.551h80.156"/>
<path id="M4_x5F_17" fill="none" stroke="#B21436" strokeWidth="1.5" strokeMiterlimit="10" d="M2457.021,2366.625v11.977h24.649 v217.949"/>
<path id="M4_x5F_16" fill="none" stroke="#B21436" strokeWidth="1.5" strokeMiterlimit="10" d="M2457.021,2288.25v78.375"/>
<path id="M4_x5F_15" fill="none" stroke="#B21436" strokeWidth="1.5" strokeMiterlimit="10" d="M2457.021,2233.313v54.938"/>
<path id="M4_x5F_14" fill="none" stroke="#B21436" strokeWidth="1.5" strokeMiterlimit="10" d="M2457.021,2183.813v49.5"/>
<path id="M4_x5F_13" fill="none" stroke="#B21436" strokeWidth="1.5" strokeMiterlimit="10" d="M2457.021,2183.813v-14.185 l45.986-45.99"/>
<path id="M4_x5F_12" fill="none" stroke="#B21436" strokeWidth="1.5" strokeMiterlimit="10" d="M2503.008,2123.638l19.015-19.015 h61.123"/>
<path id="M4_x5F_11" fill="none" stroke="#B21436" strokeWidth="1.5" strokeMiterlimit="10" d="M2583.145,2026.36v78.263"/>
<path id="M4_x5F_10" fill="none" stroke="#B21436" strokeWidth="1.5" strokeMiterlimit="10" d="M2457.518,2026.36h125.627"/>
<path id="M4_x5F_9" fill="none" stroke="#B21436" strokeWidth="1.5" strokeMiterlimit="10" d="M2366.921,1935.763l90.598,90.598"/>
<path id="M4_x5F_8" fill="none" stroke="#B21436" strokeWidth="1.5" strokeMiterlimit="10" d="M2273.45,1842.293l93.471,93.47"/>
<path id="M4_x5F_7" fill="none" stroke="#B21436" strokeWidth="1.5" strokeMiterlimit="10" d="M2212.099,1780.943l61.351,61.35"/>
<path id="M4_x5F_6" fill="none" stroke="#B21436" strokeWidth="1.5" strokeMiterlimit="10" d="M2212.099,1780.943l-40.314-40.313 "/>
<path id="M4_x5F_5" fill="none" stroke="#B21436" strokeWidth="1.5" strokeMiterlimit="10" d="M2132.488,1701.332l39.297,39.297"/>
<path id="M4_x5F_4" fill="none" stroke="#B21436" strokeWidth="1.5" strokeMiterlimit="10" d="M2089.827,1658.67l42.661,42.662"/>
<path id="M4_x5F_3" fill="none" stroke="#B21436" strokeWidth="1.5" strokeMiterlimit="10" d="M2052.288,1621.132l37.539,37.539"/>
<path id="M4_x5F_2" fill="none" stroke="#B21436" strokeWidth="1.5" strokeMiterlimit="10" d="M2015.544,1584.386l36.745,36.746"/>
<path id="M4_x5F_1" fill="none" stroke="#B21436" strokeWidth="1.5" strokeMiterlimit="10" d="M1857.804,1426.646l157.739,157.74 "/>
</g>
<g id="Layer_8">
<g>
<path fill="#B21436" d="M2583.687,2107.595c-1.638,0-2.97-1.332-2.97-2.97s1.332-2.97,2.97-2.97c1.637,0,2.969,1.332,2.969,2.97 S2585.324,2107.595,2583.687,2107.595z"/>
</g>
<path fill="#B21436" d="M2805.881,2534.248c-1.64,0-2.972-1.332-2.972-2.97s1.332-2.97,2.972-2.97c1.637,0,2.969,1.332,2.969,2.97 S2807.516,2534.248,2805.881,2534.248z"/>
<g>
<path fill="#B21436" d="M2583.686,2030.518c-1.636,0-2.967-1.331-2.967-2.967s1.331-2.967,2.967-2.967s2.967,1.331,2.967,2.967 S2585.322,2030.518,2583.686,2030.518z"/>
</g>
<g>
<path fill="#B21436" d="M2458.059,2030.518c-1.636,0-2.967-1.331-2.967-2.967s1.331-2.967,2.967-2.967s2.967,1.331,2.967,2.967 S2459.695,2030.518,2458.059,2030.518z"/>
</g>
<path fill="#B21436" d="M2457.562,2186.475c-1.636,0-2.967-1.332-2.967-2.968s1.331-2.967,2.967-2.967s2.967,1.331,2.967,2.967 S2459.198,2186.475,2457.562,2186.475z"/>
<path fill="#B21436" d="M2457.562,2236.268c-1.636,0-2.967-1.332-2.967-2.968s1.331-2.967,2.967-2.967s2.967,1.331,2.967,2.967 S2459.198,2236.268,2457.562,2236.268z"/>
<path fill="#B21436" d="M2457.562,2291.273c-1.636,0-2.967-1.332-2.967-2.968s1.331-2.967,2.967-2.967s2.967,1.331,2.967,2.967 S2459.198,2291.273,2457.562,2291.273z"/>
<circle fill="#B21436" cx="2700.288" cy="2542.87" r="2.969"/>
<circle fill="#B21436" cx="2646.456" cy="2596.553" r="2.969"/>
<path fill="#B21436" d="M2561.969,2599.521c-1.637,0-2.969-1.332-2.969-2.97c0-1.637,1.332-2.969,2.969-2.969 c1.638,0,2.97,1.332,2.97,2.969C2564.939,2598.189,2563.607,2599.521,2561.969,2599.521z"/>
<path fill="#B21436" d="M2457.562,2369.464c-1.636,0-2.967-1.331-2.967-2.967s1.331-2.967,2.967-2.967s2.967,1.331,2.967,2.967 S2459.198,2369.464,2457.562,2369.464z"/>
<g>
<path fill="#B21436" d="M2482.21,2599.52c-1.636,0-2.968-1.33-2.968-2.967c0-1.636,1.332-2.967,2.968-2.967 c1.637,0,2.968,1.331,2.968,2.967C2485.177,2598.189,2483.845,2599.52,2482.21,2599.52z"/>
</g>
<g>
<path fill="#B21436" d="M2503.431,2126.729c-1.638,0-2.968-1.332-2.968-2.968s1.33-2.968,2.968-2.968 c1.637,0,2.968,1.332,2.968,2.968S2505.068,2126.729,2503.431,2126.729z"/>
</g>
<path fill="#B21436" d="M2946.619,2534.248c-1.637,0-2.969-1.332-2.969-2.97s1.332-2.97,2.969-2.97c1.638,0,2.97,1.332,2.97,2.97 S2948.258,2534.248,2946.619,2534.248z"/>
<g>
<path fill="#B21436" d="M2946.61,2723.278c-1.637,0-2.968-1.332-2.968-2.968c0-1.638,1.331-2.97,2.968-2.97 s2.969,1.332,2.969,2.97C2949.579,2721.947,2948.247,2723.278,2946.61,2723.278z"/>
</g>
<g>
<path fill="#B21436" d="M2994.676,2820.653c-1.636,0-2.968-1.332-2.968-2.968c0-1.637,1.332-2.968,2.968-2.968 s2.967,1.331,2.967,2.968C2997.641,2819.322,2996.31,2820.653,2994.676,2820.653z"/>
</g>
<path fill="#B21436" d="M3112.772,2938.729c-1.637,0-2.968-1.332-2.968-2.969c0-1.636,1.331-2.968,2.968-2.968 s2.968,1.332,2.968,2.968C3115.74,2937.396,3114.409,2938.729,3112.772,2938.729z"/>
<g>
<path fill="#B21436" d="M3188.532,3014.521c-1.637,0-2.968-1.332-2.968-2.969c0-1.636,1.331-2.968,2.968-2.968 s2.969,1.332,2.969,2.968C3191.501,3013.189,3190.169,3014.521,3188.532,3014.521z"/>
</g>
<g>
<path fill="#B21436" d="M3253.472,3079.457c-1.638,0-2.968-1.331-2.968-2.967c0-1.637,1.33-2.967,2.968-2.967 c1.636,0,2.967,1.33,2.967,2.967C3256.439,3078.126,3255.108,3079.457,3253.472,3079.457z"/>
</g>
<g>
<path fill="#B21436" d="M3349.292,3175.286c-1.637,0-2.968-1.331-2.968-2.968c0-1.636,1.331-2.968,2.968-2.968 s2.968,1.332,2.968,2.968C3352.26,3173.955,3350.927,3175.286,3349.292,3175.286z"/>
</g>
<g>
<path fill="#B21436" d="M3392.807,3218.786c-1.636,0-2.967-1.331-2.967-2.968c0-1.636,1.331-2.968,2.967-2.968 s2.967,1.332,2.967,2.968C3395.774,3217.455,3394.443,3218.786,3392.807,3218.786z"/>
</g>
<g>
<path fill="#B21436" d="M3498.712,3324.697c-1.636,0-2.967-1.332-2.967-2.969s1.331-2.967,2.967-2.967 c1.638,0,2.969,1.33,2.969,2.967C3501.679,3323.365,3500.348,3324.697,3498.712,3324.697z"/>
</g>
<g>
<path fill="#B21436" d="M3696.788,3724.678c-1.637,0-2.968-1.332-2.968-2.967c0-1.637,1.331-2.967,2.968-2.967 s2.968,1.33,2.968,2.967C3699.756,3723.346,3698.425,3724.678,3696.788,3724.678z"/>
</g>
<g>
<path fill="#B21436" d="M3696.788,3805.133c-1.637,0-2.968-1.332-2.968-2.967c0-1.637,1.331-2.967,2.968-2.967 s2.968,1.33,2.968,2.967C3699.756,3803.801,3698.425,3805.133,3696.788,3805.133z"/>
</g>
<g>
<path fill="#B21436" d="M3696.788,3919.344c-1.637,0-2.968-1.332-2.968-2.967c0-1.637,1.331-2.967,2.968-2.967 s2.968,1.33,2.968,2.967C3699.756,3918.012,3698.425,3919.344,3696.788,3919.344z"/>
</g>
<g>
<path fill="#B21436" d="M3696.788,4113.354c-1.637,0-2.968-1.332-2.968-2.967c0-1.637,1.331-2.967,2.968-2.967 s2.968,1.33,2.968,2.967C3699.756,4112.021,3698.425,4113.354,3696.788,4113.354z"/>
</g>
<g>
<path fill="#B21436" d="M3696.413,4214.142c-1.637,0-2.968-1.332-2.968-2.967c0-1.637,1.331-2.967,2.968-2.967 s2.968,1.33,2.968,2.967C3699.381,4212.81,3698.05,4214.142,3696.413,4214.142z"/>
</g>
<g>
<path fill="#B21436" d="M3696.792,3522.764c-1.636,0-2.967-1.332-2.967-2.967c0-1.637,1.331-2.967,2.967-2.967 c1.638,0,2.969,1.33,2.969,2.967C3699.76,3521.432,3698.428,3522.764,3696.792,3522.764z"/>
</g>
<path fill="#B21436" d="M1858.345,1429.613c-1.636,0-2.968-1.331-2.968-2.967c0-1.637,1.332-2.969,2.968-2.969 s2.967,1.332,2.967,2.969C1861.312,1428.282,1859.981,1429.613,1858.345,1429.613z"/>
<path fill="#B21436" d="M2015.488,1587.447c-1.636,0-2.968-1.332-2.968-2.969s1.332-2.969,2.968-2.969s2.968,1.332,2.968,2.969 C2018.456,1586.116,2017.124,1587.447,2015.488,1587.447z"/>
<path fill="#B21436" d="M2052.195,1624.158c-1.636,0-2.967-1.331-2.967-2.967c0-1.637,1.331-2.969,2.967-2.969 s2.968,1.332,2.968,2.969C2055.163,1622.827,2053.831,1624.158,2052.195,1624.158z"/>
<path fill="#B21436" d="M2090.087,1661.352c-1.637,0-2.969-1.332-2.969-2.969c0-1.636,1.332-2.968,2.969-2.968 s2.969,1.332,2.969,2.968C2093.054,1660.02,2091.723,1661.352,2090.087,1661.352z"/>
<path fill="#B21436" d="M2132.844,1704.112c-1.637,0-2.967-1.332-2.967-2.968c0-1.637,1.33-2.968,2.967-2.968 c1.636,0,2.967,1.331,2.967,2.968S2134.48,1704.112,2132.844,1704.112z"/>
<path fill="#B21436" d="M2171.967,1743.355c-1.638,0-2.97-1.332-2.97-2.97c0-1.636,1.332-2.968,2.97-2.968 c1.636,0,2.968,1.332,2.968,2.968C2174.933,1742.024,2173.602,1743.355,2171.967,1743.355z"/>
<path fill="#B21436" d="M2212.559,1783.287c-1.636,0-2.967-1.331-2.967-2.967c0-1.637,1.331-2.969,2.967-2.969 s2.967,1.332,2.967,2.969C2215.526,1781.956,2214.195,1783.287,2212.559,1783.287z"/>
<path fill="#B21436" d="M2273.734,1844.998c-1.636,0-2.967-1.331-2.967-2.967c0-1.637,1.331-2.967,2.967-2.967 s2.968,1.33,2.968,2.967C2276.702,1843.667,2275.37,1844.998,2273.734,1844.998z"/>
<path fill="#B21436" d="M2367.177,1938.439c-1.637,0-2.967-1.332-2.967-2.968s1.33-2.967,2.967-2.967 c1.636,0,2.967,1.331,2.967,2.967C2370.143,1937.109,2368.812,1938.439,2367.177,1938.439z"/>
<rect x="204.085" y="190.131" fill="#B21436" width="51.005" height="51.005"/>
</g>
</svg>
</ReactSVGPanZoom>
);
}
}
ReactDOM.render(
<div><Example /></div>,
document.getElementById('container')
);
body {
margin: 0;
background-color: rgba(0, 0, 0, 0.05);
background-image: repeating-linear-gradient(0deg, transparent, transparent 7px, rgba(0, 0, 0, 0.2) 1px, transparent 8px), repeating-linear-gradient(90deg, transparent, transparent 7px, rgba(0, 0, 0, 0.2) 1px, transparent 8px);
background-size: 8px 8px;
}
#container {
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
padding: 10px;
}
<script src="https://unpkg.com/react-svg-pan-zoom@2.16.1/build-umd/react-svg-pan-zoom.min.js"></script>
<script src="https://unpkg.com/prop-types@15.5.10/prop-types.js"></script>
<script src="https://unpkg.com/react-dom@15.5.4/dist/react-dom.js"></script>
<script src="https://unpkg.com/react@15.5.4/dist/react.js"></script>
<script src="https://unpkg.com/babel-standalone@6/babel.min.js"></script>
<div id="container"></div>
最佳答案
不确定您想要实现什么以及您如何决定这些“固定宽度和高度。
但这是代码的工作版本: https://jsfiddle.net/tzookb/79742ncq/
现在请定义您想要实现的目标,以便我可以提供帮助。
我已经与 svg 和 React 对抗了很长时间。
快速更新您的代码:
const width = window.innerWidth - 20;
const height= window.innerHeight - 20;
return (
<ReactSVGPanZoom
width={width} height={height} scaleFactorMin={0.99}
onClick={event => console.log(event.x, event.y, event.originalEvent)}>
关于jquery - 大尺寸的 svg 无法正常工作如何在 React-pan-zoon-svg 中设置大 svg?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50059042/
我通过 spring ioc 编写了一些 Rest 应用程序。但我无法解决这个问题。这是我的异常(exception): org.springframework.beans.factory.BeanC
我对 TestNG、Spring 框架等完全陌生,我正在尝试使用注释 @Value通过 @Configuration 访问配置文件注释。 我在这里想要实现的目标是让控制台从配置文件中写出“hi”,通过
为此工作了几个小时。我完全被难住了。 这是 CS113 的实验室。 如果用户在程序(二进制计算器)结束时选择继续,我们需要使用 goto 语句来到达程序的顶部。 但是,我们还需要释放所有分配的内存。
我正在尝试使用 ffmpeg 库构建一个小的 C 程序。但是我什至无法使用 avformat_open_input() 打开音频文件设置检查错误代码的函数后,我得到以下输出: Error code:
使用 Spring Initializer 创建一个简单的 Spring boot。我只在可用选项下选择 DevTools。 创建项目后,无需对其进行任何更改,即可正常运行程序。 现在,当我尝试在项目
所以我只是在 Mac OS X 中通过 brew 安装了 qt。但是它无法链接它。当我尝试运行 brew link qt 或 brew link --overwrite qt 我得到以下信息: ton
我在提交和 pull 时遇到了问题:在提交的 IDE 中,我看到: warning not all local changes may be shown due to an error: unable
我跑 man gcc | grep "-L" 我明白了 Usage: grep [OPTION]... PATTERN [FILE]... Try `grep --help' for more inf
我有一段代码,旨在接收任何 URL 并将其从网络上撕下来。到目前为止,它运行良好,直到有人给了它这个 URL: http://www.aspensurgical.com/static/images/a
在过去的 5 个小时里,我一直在尝试在我的服务器上设置 WireGuard,但在完成所有设置后,我无法 ping IP 或解析域。 下面是服务器配置 [Interface] Address = 10.
我正在尝试在 GitLab 中 fork 我的一个私有(private)项目,但是当我按下 fork 按钮时,我会收到以下信息: No available namespaces to fork the
我这里遇到了一些问题。我是 node.js 和 Rest API 的新手,但我正在尝试自学。我制作了 REST API,使用 MongoDB 与我的数据库进行通信,我使用 Postman 来测试我的路
下面的代码在控制台中给出以下消息: Uncaught DOMException: Failed to execute 'appendChild' on 'Node': The new child el
我正在尝试调用一个新端点来显示数据,我意识到在上一组有效的数据中,它在数据周围用一对额外的“[]”括号进行控制台,我认为这就是问题是,而新端点不会以我使用数据的方式产生它! 这是 NgFor 失败的原
我正在尝试将我的 Symfony2 应用程序部署到我的 Azure Web 应用程序,但遇到了一些麻烦。 推送到远程时,我在终端中收到以下消息 remote: Updating branch 'mas
Minikube已启动并正在运行,没有任何错误,但是我无法 curl IP。我在这里遵循:https://docs.traefik.io/user-guide/kubernetes/,似乎没有提到关闭
每当我尝试docker组成任何项目时,都会出现以下错误。 我尝试过有和没有sudo 我在这台机器上只有这个问题。我可以在Mac和Amazon WorkSpace上运行相同的容器。 (myslabs)
我正在尝试 pip install stanza 并收到此消息: ERROR: No matching distribution found for torch>=1.3.0 (from stanza
DNS 解析看起来不错,但我无法 ping 我的服务。可能是什么原因? 来自集群中的另一个 Pod: $ ping backend PING backend.default.svc.cluster.l
我正在使用Hibernate 4 + Spring MVC 4当我开始 Apache Tomcat Server 8我收到此错误: Error creating bean with name 'wel
我是一名优秀的程序员,十分优秀!