ISSUE-017 - Figured out how to allow for Transition and Dragging on the same element.

The secret? Don't! Use another throw-away div and put it around the draggable div.
Also adopted animated.div into the Styled-Component. Really cool how it just works.
This commit is contained in:
Kyle Geib committed 2022-01-12 14:52:38 -05:00
1 parent 9541306894
commit a6a5eb7751
2 files changed
+35 -15

No files matched your search

@@ -1,3 +1,4 @@
import { animated } from "@react-spring/web";
import styled from "styled-components";
import { OverlayPosition } from "../../../types/state";
@@ -11,8 +12,8 @@ export const OverlayItemContainer = styled.div.attrs<OverlayItemContainerProps>(
visible,
}) => ({
style: {
// top: y,
// left: x,
top: y,
left: x,
display: visible ? undefined : "none",
},
}))<OverlayItemContainerProps>`
@@ -24,3 +25,23 @@ export const OverlayItemContainer = styled.div.attrs<OverlayItemContainerProps>(
`;
OverlayItemContainer.displayName = "OverlayItemContainer";
type AnimatedOverlayItemContainerProps = {
visible: boolean,
}
export const AnimatedOverlayItemContainer = styled(animated.div).attrs<AnimatedOverlayItemContainerProps>(({
visible,
}) => ({
style: {
display: visible ? undefined : "none",
},
}))<AnimatedOverlayItemContainerProps>`
position: absolute;
z-index: 1;
/* Temporary. Overlay will be transparent and based on an image. */
width: 150px;
height: 150px;
background-color: white;
box-shadow: 0px 7px 11px 1px black;
`;