|
@@ -9,13 +9,13 @@ export interface KrpanoMiddlewareMethods {
|
|
|
ready: () => void
|
|
|
}
|
|
|
|
|
|
+const isMobile = /Mobi|Android|iPhone/i.test(navigator.userAgent)
|
|
|
+
|
|
|
export const KrpanoMiddleware = forwardRef<KrpanoMiddlewareMethods, KrpanoMiddlewareProps>(
|
|
|
({ children }, ref) => {
|
|
|
+ const rootStyle = useSelector((state: any) => state.A0Layout.style)
|
|
|
const isHH = useSelector((state: any) => state.A0Layout.isHH)
|
|
|
- const fakeEvent = useMemo(
|
|
|
- () => !isHH && /Mobi|Android|iPhone/i.test(navigator.userAgent),
|
|
|
- [isHH]
|
|
|
- )
|
|
|
+ const fakeEvent = useMemo(() => !isHH && isMobile, [isHH])
|
|
|
const startX = useRef(0)
|
|
|
const startY = useRef(0)
|
|
|
|
|
@@ -49,6 +49,7 @@ export const KrpanoMiddleware = forwardRef<KrpanoMiddlewareMethods, KrpanoMiddle
|
|
|
|
|
|
useImperativeHandle(ref, () => ({
|
|
|
ready: () => {
|
|
|
+ console.log(rootStyle)
|
|
|
if (fakeEvent) {
|
|
|
window.ReactKrpanoActionProxy?.krpanoRenderer?.call("set(control.usercontrol, 'off');")
|
|
|
}
|
|
@@ -65,7 +66,19 @@ export const KrpanoMiddleware = forwardRef<KrpanoMiddlewareMethods, KrpanoMiddle
|
|
|
|
|
|
return (
|
|
|
<div
|
|
|
- style={{ width: '100%', height: '100%' }}
|
|
|
+ style={
|
|
|
+ !isMobile && Object.keys(rootStyle).length
|
|
|
+ ? {
|
|
|
+ position: 'relative',
|
|
|
+ left: `-${(window.innerWidth - rootStyle.width) / 2}px`,
|
|
|
+ width: '100vw',
|
|
|
+ height: '100vh',
|
|
|
+ transform: `translate(${rootStyle.moveX * -1}px, ${rootStyle.moveY * -1}px) scale(${
|
|
|
+ 1 / rootStyle.sizeW
|
|
|
+ }, ${1 / rootStyle.sizeH})`
|
|
|
+ }
|
|
|
+ : { width: '100%', height: '100%' }
|
|
|
+ }
|
|
|
onTouchStart={handleTouchStart}
|
|
|
onTouchMove={handleTouchMove}
|
|
|
>
|