Skip to content
Snippets Groups Projects
Commit ab14942c authored by Evelyn Eastmond's avatar Evelyn Eastmond
Browse files

Starting to play with Draggable for cards.

parent 908cb2e5
No related branches found
No related tags found
No related merge requests found
...@@ -9,6 +9,12 @@ ...@@ -9,6 +9,12 @@
min-width: 468px; min-width: 468px;
} }
.card-container-overlay {
margin: auto;
pointer-events: none;
overflow: hidden;
}
.left-card, .right-card { .left-card, .right-card {
height: 90%; height: 90%;
position: absolute; position: absolute;
......
...@@ -3,6 +3,7 @@ import React, {Fragment} from 'react'; ...@@ -3,6 +3,7 @@ import React, {Fragment} from 'react';
import classNames from 'classnames'; import classNames from 'classnames';
import {FormattedMessage} from 'react-intl'; import {FormattedMessage} from 'react-intl';
import Draggable from 'react-draggable'; import Draggable from 'react-draggable';
import Box from '../box/box.jsx';
import styles from './card.css'; import styles from './card.css';
...@@ -277,55 +278,64 @@ const Cards = props => { ...@@ -277,55 +278,64 @@ const Cards = props => {
const steps = content[activeDeckId].steps; const steps = content[activeDeckId].steps;
return ( return (
<Draggable <Box
bounds="parent" // Use static `cards-overlay` class for bounds of draggables
position={{x: x, y: y}} className={styles.cardContainerOverlay}
onDrag={onDrag} style={{
onStart={onStartDrag} width: 500, // props.stageSize.width,
onStop={onEndDrag} height: 500 // props.stageSize.height
}}
> >
<div className={styles.cardContainer}> <Draggable
<div className={styles.card}> bounds="parent"
<CardHeader position={{x: x, y: y}}
expanded={expanded} onDrag={onDrag}
step={step} onStart={onStartDrag}
totalSteps={steps.length} onStop={onEndDrag}
onCloseCards={onCloseCards} >
onShowAll={onShowAll} <div className={styles.cardContainer}>
onShrinkExpandCards={onShrinkExpandCards} <div className={styles.card}>
/> <CardHeader
<div className={expanded ? styles.stepBody : styles.hidden}> expanded={expanded}
{steps[step].deckIds ? ( step={step}
<PreviewsStep totalSteps={steps.length}
content={content} onCloseCards={onCloseCards}
deckIds={steps[step].deckIds} onShowAll={onShowAll}
onActivateDeckFactory={onActivateDeckFactory} onShrinkExpandCards={onShrinkExpandCards}
onShowAll={onShowAll} />
/> <div className={expanded ? styles.stepBody : styles.hidden}>
) : ( {steps[step].deckIds ? (
steps[step].video ? ( <PreviewsStep
<VideoStep content={content}
dragging={dragging} deckIds={steps[step].deckIds}
video={translateVideo(steps[step].video, locale)} onActivateDeckFactory={onActivateDeckFactory}
onShowAll={onShowAll}
/> />
) : ( ) : (
<ImageStep steps[step].video ? (
image={translateImage(steps[step].image, locale)} <VideoStep
title={steps[step].title} dragging={dragging}
/> video={translateVideo(steps[step].video, locale)}
) />
)} ) : (
{steps[step].trackingPixel && steps[step].trackingPixel} <ImageStep
image={translateImage(steps[step].image, locale)}
title={steps[step].title}
/>
)
)}
{steps[step].trackingPixel && steps[step].trackingPixel}
</div>
<NextPrevButtons
expanded={expanded}
isRtl={isRtl}
onNextStep={step < steps.length - 1 ? onNextStep : null}
onPrevStep={step > 0 ? onPrevStep : null}
/>
</div> </div>
<NextPrevButtons
expanded={expanded}
isRtl={isRtl}
onNextStep={step < steps.length - 1 ? onNextStep : null}
onPrevStep={step > 0 ? onPrevStep : null}
/>
</div> </div>
</div> </Draggable>
</Draggable> </Box>
); );
}; };
......
...@@ -31,6 +31,8 @@ const reducer = function (state, action) { ...@@ -31,6 +31,8 @@ const reducer = function (state, action) {
visible: false visible: false
}); });
case SHRINK_EXPAND_CARDS: case SHRINK_EXPAND_CARDS:
// Set new position here based on bounds
console.log('TODO: set new position based on bounds');
return Object.assign({}, state, { return Object.assign({}, state, {
expanded: !state.expanded expanded: !state.expanded
}); });
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment