Skip to content
Open
Show file tree
Hide file tree
Changes from all 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
18 changes: 0 additions & 18 deletions src/components/Datepicker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -166,24 +166,6 @@ const Datepicker: React.FC<DatepickerType> = ({
/* End Second */

// UseEffects & UseLayoutEffect
useEffect(() => {
const container = containerRef.current;
const calendarContainer = calendarContainerRef.current;
const arrow = arrowRef.current;

if (container && calendarContainer && arrow) {
const detail = container.getBoundingClientRect();
const screenCenter = window.innerWidth / 2;
const containerCenter = (detail.right - detail.x) / 2 + detail.x;

if (containerCenter > screenCenter) {
arrow.classList.add("right-0");
arrow.classList.add("mr-3.5");
calendarContainer.classList.add("right-0");
}
}
}, []);

useEffect(() => {
if (value && value.startDate && value.endDate) {
const startDate = dayjs(value.startDate);
Expand Down
21 changes: 21 additions & 0 deletions src/components/Input.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,27 @@ const Input: React.FC<Props> = (e: Props) => {
arrow.classList.remove("border-t");
}

if (input && div && arrow) {
const detail = input.getBoundingClientRect();
const screenCenter = window.innerWidth / 2;
const containerCenter = detail.width / 2 + detail.left;
const screenLeftToContainerRight = detail.right;
const calendarWidth = div.getBoundingClientRect().width;

if (
containerCenter > screenCenter &&
screenLeftToContainerRight > calendarWidth
) {
arrow.classList.add("right-0");
arrow.classList.add("mr-3.5");
div.classList.add("right-0");
} else {
arrow.classList.remove("right-0");
arrow.classList.remove("mr-3.5");
div.classList.remove("right-0");
}
}

setTimeout(() => {
div.classList.remove("translate-y-4");
div.classList.remove("opacity-0");
Expand Down