🐛 fix resize bug
This commit is contained in:
parent
7eb775d1e3
commit
959bbedcfa
@ -3,10 +3,10 @@
|
|||||||
.root {
|
.root {
|
||||||
.content {
|
.content {
|
||||||
display: flex;
|
display: flex;
|
||||||
|
|
||||||
.sides {
|
.sides {
|
||||||
min-height: calc(100vh - 83px);
|
min-height: calc(100vh - 83px);
|
||||||
flex: 1;
|
height: fit-content;
|
||||||
|
width: 50%;
|
||||||
@media (max-width: $screen-m) {
|
@media (max-width: $screen-m) {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
}
|
}
|
||||||
|
@ -5,6 +5,7 @@ import Image, { StaticImageData } from "next/image";
|
|||||||
import React, { ReactNode, useEffect, useRef } from "react";
|
import React, { ReactNode, useEffect, useRef } from "react";
|
||||||
|
|
||||||
import classes from "./classes.module.scss";
|
import classes from "./classes.module.scss";
|
||||||
|
import { useWindowSize } from "@uidotdev/usehooks";
|
||||||
|
|
||||||
type IProps = {
|
type IProps = {
|
||||||
title: string;
|
title: string;
|
||||||
@ -30,9 +31,22 @@ export default function DefaultDoubleSidePage(props: IProps) {
|
|||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
// make second element ref height same as first element ref height
|
// make second element ref height same as first element ref height
|
||||||
if (firstElementRef.current && secondElementRef.current) {
|
const resizeObserver = new ResizeObserver(() => {
|
||||||
secondElementRef.current.style.height = `${firstElementRef.current.clientHeight}px`;
|
if (secondElementRef.current && firstElementRef.current) {
|
||||||
|
console.log("Recalculate");
|
||||||
|
if (secondElementRef.current.clientHeight !== 0) {
|
||||||
|
secondElementRef.current.style.height = `0px`;
|
||||||
|
}
|
||||||
|
|
||||||
|
secondElementRef.current.style.height = `${firstElementRef.current.clientHeight}px`;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
if (firstElementRef.current) {
|
||||||
|
resizeObserver.observe(firstElementRef.current);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return () => resizeObserver.disconnect();
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
const firstElementRef = useRef<HTMLDivElement>(null);
|
const firstElementRef = useRef<HTMLDivElement>(null);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user