Skip to content

Commit ab14942

Browse files
committed
Starting to play with Draggable for cards.
1 parent 908cb2e commit ab14942

File tree

3 files changed

+62
-44
lines changed

3 files changed

+62
-44
lines changed

src/components/cards/card.css

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,12 @@
99
min-width: 468px;
1010
}
1111

12+
.card-container-overlay {
13+
margin: auto;
14+
pointer-events: none;
15+
overflow: hidden;
16+
}
17+
1218
.left-card, .right-card {
1319
height: 90%;
1420
position: absolute;

src/components/cards/cards.jsx

Lines changed: 54 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import React, {Fragment} from 'react';
33
import classNames from 'classnames';
44
import {FormattedMessage} from 'react-intl';
55
import Draggable from 'react-draggable';
6+
import Box from '../box/box.jsx';
67

78
import styles from './card.css';
89

@@ -277,55 +278,64 @@ const Cards = props => {
277278
const steps = content[activeDeckId].steps;
278279

279280
return (
280-
<Draggable
281-
bounds="parent"
282-
position={{x: x, y: y}}
283-
onDrag={onDrag}
284-
onStart={onStartDrag}
285-
onStop={onEndDrag}
281+
<Box
282+
// Use static `cards-overlay` class for bounds of draggables
283+
className={styles.cardContainerOverlay}
284+
style={{
285+
width: 500, // props.stageSize.width,
286+
height: 500 // props.stageSize.height
287+
}}
286288
>
287-
<div className={styles.cardContainer}>
288-
<div className={styles.card}>
289-
<CardHeader
290-
expanded={expanded}
291-
step={step}
292-
totalSteps={steps.length}
293-
onCloseCards={onCloseCards}
294-
onShowAll={onShowAll}
295-
onShrinkExpandCards={onShrinkExpandCards}
296-
/>
297-
<div className={expanded ? styles.stepBody : styles.hidden}>
298-
{steps[step].deckIds ? (
299-
<PreviewsStep
300-
content={content}
301-
deckIds={steps[step].deckIds}
302-
onActivateDeckFactory={onActivateDeckFactory}
303-
onShowAll={onShowAll}
304-
/>
305-
) : (
306-
steps[step].video ? (
307-
<VideoStep
308-
dragging={dragging}
309-
video={translateVideo(steps[step].video, locale)}
289+
<Draggable
290+
bounds="parent"
291+
position={{x: x, y: y}}
292+
onDrag={onDrag}
293+
onStart={onStartDrag}
294+
onStop={onEndDrag}
295+
>
296+
<div className={styles.cardContainer}>
297+
<div className={styles.card}>
298+
<CardHeader
299+
expanded={expanded}
300+
step={step}
301+
totalSteps={steps.length}
302+
onCloseCards={onCloseCards}
303+
onShowAll={onShowAll}
304+
onShrinkExpandCards={onShrinkExpandCards}
305+
/>
306+
<div className={expanded ? styles.stepBody : styles.hidden}>
307+
{steps[step].deckIds ? (
308+
<PreviewsStep
309+
content={content}
310+
deckIds={steps[step].deckIds}
311+
onActivateDeckFactory={onActivateDeckFactory}
312+
onShowAll={onShowAll}
310313
/>
311314
) : (
312-
<ImageStep
313-
image={translateImage(steps[step].image, locale)}
314-
title={steps[step].title}
315-
/>
316-
)
317-
)}
318-
{steps[step].trackingPixel && steps[step].trackingPixel}
315+
steps[step].video ? (
316+
<VideoStep
317+
dragging={dragging}
318+
video={translateVideo(steps[step].video, locale)}
319+
/>
320+
) : (
321+
<ImageStep
322+
image={translateImage(steps[step].image, locale)}
323+
title={steps[step].title}
324+
/>
325+
)
326+
)}
327+
{steps[step].trackingPixel && steps[step].trackingPixel}
328+
</div>
329+
<NextPrevButtons
330+
expanded={expanded}
331+
isRtl={isRtl}
332+
onNextStep={step < steps.length - 1 ? onNextStep : null}
333+
onPrevStep={step > 0 ? onPrevStep : null}
334+
/>
319335
</div>
320-
<NextPrevButtons
321-
expanded={expanded}
322-
isRtl={isRtl}
323-
onNextStep={step < steps.length - 1 ? onNextStep : null}
324-
onPrevStep={step > 0 ? onPrevStep : null}
325-
/>
326336
</div>
327-
</div>
328-
</Draggable>
337+
</Draggable>
338+
</Box>
329339
);
330340
};
331341

src/reducers/cards.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ const reducer = function (state, action) {
3131
visible: false
3232
});
3333
case SHRINK_EXPAND_CARDS:
34+
// Set new position here based on bounds
35+
console.log('TODO: set new position based on bounds');
3436
return Object.assign({}, state, {
3537
expanded: !state.expanded
3638
});

0 commit comments

Comments
 (0)