Skip to content

Commit 012fcf6

Browse files
committed
merge master
2 parents 1734cab + 892bf27 commit 012fcf6

File tree

11 files changed

+247
-23
lines changed

11 files changed

+247
-23
lines changed

README.markdown

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,7 @@ The deck tag is the top level tag and there should only be one of them. It suppo
181181
|---|---|---|
182182
|transition|React.PropTypes.array|Accepts `slide`, `zoom`, `fade` or `spin`, and can be combined. Sets global slide transitions. **Note: If you use the 'scale' transition, fitted text won't work in Safari.**|
183183
|transitionDuration| React.PropTypes.number| Accepts integer value in milliseconds for global transition duration.
184+
|progress| React.PropTypes.string|Accepts `pacman`, `bar`, `number` or `none`.
184185
185186
####\<Slide /> (Base)
186187
@@ -191,6 +192,7 @@ The slide tag represents each slide in the presentation. It supports the followi
191192
|align| React.PropTypes.string | Accepts a space delimited value for positioning interior content. The first value can be `flex-start` (left), `center` (middle), or `flex-end` (bottom). The second value can be `flex-start` (top) , `center` (middle), or `flex-end` (bottom). You would provide this prop like `align="center middle"`, which is it's default.
192193
|transition|React.PropTypes.array|Accepts `slide`, `zoom`, `fade` or `spin`, and can be combined. Sets the slide transition. **Note: If you use the 'scale' transition, fitted text won't work in Safari.**|
193194
|transitionDuration| React.PropTypes.number| Accepts integer value in milliseconds for slide transition duration.
195+
|notes| React.PropTypes.stings| Text which will appear in the presenter mode. Can be HTML.
194196
195197
###Layout Tags
196198

presentation/deck.jsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,13 @@ export default class extends React.Component {
3636
</Link>
3737
<Text textSize="1.5em" margin="20px 0px 0px" bold>Hit Your Right Arrow To Begin!</Text>
3838
</Slide>
39-
<Slide transition={["slide"]} bgColor="black">
40-
<Image src={images.kat.replace("/", "")} margin="0px auto 40px" height="293px"/>
39+
<Slide transition={['slide']} bgColor="black" notes="You can even put notes on your slide. How awesome is that?">
40+
<Image src={images.kat.replace('/','')} margin="0px auto 40px" height="293px"/>
4141
<Heading size={1} fit textColor="primary" textFont="secondary">
4242
Wait what?
4343
</Heading>
4444
</Slide>
45-
<Slide transition={["zoom", "fade"]} bgColor="primary">
45+
<Slide transition={['zoom', 'fade']} bgColor="primary" notes="<ul><li>talk about that</li><li>and that</li></ul>">
4646
<CodePane
4747
lang="javascript"
4848
source={require("raw!./deck.example")}

src/appear.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ const Appear = React.createClass({
5757
opacity: this.getTweeningValue("opacity")
5858
};
5959
return (
60-
<div style={styles} className="appear">
60+
<div style={styles} className="fragment">
6161
{this.props.children}
6262
</div>
6363
);

src/base.jsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,11 +52,16 @@ const getStyles = function getStyles() {
5252
styles.backgroundColor = color;
5353
}
5454
if (this.props.bgImage) {
55-
styles.backgroundImage =
55+
if (this.props.bgDarken) {
56+
styles.backgroundImage =
5657
"linear-gradient( rgba(0, 0, 0, " + this.props.bgDarken +
5758
"), rgba(0, 0, 0, " + this.props.bgDarken +
5859
") ), url(" + this.props.bgImage + ")";
60+
} else {
61+
styles.backgroundImage = "url(" + this.props.bgImage + ")";
62+
}
5963
styles.backgroundSize = "cover";
64+
styles.backgroundPosition = "center center";
6065
}
6166
return styles;
6267
};

src/deck.jsx

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import assign from "object-assign";
66
import cloneWithProps from "react/lib/cloneWithProps";
77
import Radium from "radium";
88
import _ from "lodash";
9-
109
import Presenter from "./presenter";
1110
import Export from "./export";
1211
import Overview from "./overview";
@@ -15,6 +14,7 @@ React.initializeTouchEvents(true);
1514

1615
const Style = Radium.Style;
1716

17+
import Progress from "./progress";
1818
const TransitionGroup = Radium(React.addons.TransitionGroup);
1919

2020
@Radium
@@ -50,10 +50,12 @@ class Deck extends React.Component {
5050
}
5151
_handleKeyPress(e) {
5252
const event = window.event ? window.event : e;
53-
if (event.keyCode === 37) { // left arrow
53+
// left, page down
54+
if (event.keyCode === 37 || event.keyCode === 33) {
5455
this._prevSlide();
5556
}
56-
if (event.keyCode === 39) { // right arrow
57+
// right, page up
58+
if (event.keyCode === 39 || event.keyCode === 34) {
5759
this._nextSlide();
5860
}
5961
if (event.keyCode === 79) { // o
@@ -131,7 +133,7 @@ class Deck extends React.Component {
131133
if (this.context.presenter || this.context.overview) {
132134
const main = document.querySelector(".spectacle-presenter-main");
133135
if (main) {
134-
const frags = main.querySelectorAll(".appear");
136+
const frags = main.querySelectorAll(".fragment");
135137
if (!frags.length) {
136138
return true;
137139
}
@@ -281,13 +283,13 @@ class Deck extends React.Component {
281283
top: 0,
282284
left: 0,
283285
width: "100%",
284-
height: "100%",
285-
perspective: 1000,
286-
transformStyle: "preserve-3d"
286+
height: "100%"
287287
},
288288
transition: {
289289
height: "100%",
290-
width: "100%"
290+
width: "100%",
291+
perspective: 1000,
292+
transformStyle: "flat"
291293
}
292294
};
293295

@@ -312,6 +314,10 @@ class Deck extends React.Component {
312314
onClick={this._handleClick}
313315
{...this._getTouchEvents()}>
314316
{componentToRender}
317+
{!this.context.export ? <Progress
318+
items={this.props.children}
319+
currentSlide={this.context.slide}
320+
type={this.props.progress}/> : ""}
315321
<Style rules={assign(this.context.styles.global, globals)} />
316322
</div>
317323
);
@@ -321,13 +327,15 @@ class Deck extends React.Component {
321327
Deck.displayName = "Deck";
322328

323329
Deck.defaultProps = {
324-
transitionDuration: 500
330+
transitionDuration: 500,
331+
progress: "pacman"
325332
};
326333

327334
Deck.propTypes = {
328335
children: React.PropTypes.node,
329336
transition: React.PropTypes.array,
330-
transitionDuration: React.PropTypes.number
337+
transitionDuration: React.PropTypes.number,
338+
progress: React.PropTypes.oneOf(["pacman", "bar", "number", "none"])
331339
};
332340

333341
Deck.contextTypes = {

src/presenter.jsx

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/*global setInterval*/
1+
/*global setInterval clearInterval*/
22

33
import React from "react/addons";
44
import cloneWithProps from "react/lib/cloneWithProps";
@@ -41,12 +41,15 @@ class Presenter extends Base {
4141
});
4242
}
4343
componentDidMount() {
44-
setInterval(()=> {
44+
this.time = setInterval(()=> {
4545
this.setState({
4646
time: startTime(new Date())
4747
});
4848
}, 1000);
4949
}
50+
componentWillUnmount() {
51+
clearInterval(this.time);
52+
}
5053
_renderNextSlide() {
5154
const presenterStyle = {
5255
position: "relative"
@@ -69,6 +72,11 @@ class Presenter extends Base {
6972
appearOff: true
7073
}) : <h1 style={[endStyle]}>END</h1>;
7174
}
75+
_renderNotes() {
76+
const child = this.props.slides[this.props.slide];
77+
if (!child.props.notes) { return false; }
78+
return <div dangerouslySetInnerHTML={{__html: child.props.notes}} />;
79+
}
7280
render() {
7381
const styles = {
7482
presenter: {
@@ -133,6 +141,18 @@ class Presenter extends Base {
133141
margin: 20,
134142
position: "relative",
135143
color: "white"
144+
},
145+
notes: {
146+
position: "absolute",
147+
display: "block",
148+
color: "white",
149+
width: "100%",
150+
height: "20%",
151+
bottom: "0px",
152+
textAlign: "left",
153+
padding: "20px 50px",
154+
columnCount: "2",
155+
fontSize: "0.8em"
136156
}
137157
};
138158
return (
@@ -151,6 +171,9 @@ class Presenter extends Base {
151171
{this._renderNextSlide()}
152172
</div>
153173
</div>
174+
<div className="spectacle-presenter-notes" style={[styles.notes]}>
175+
{this._renderNotes()}
176+
</div>
154177
</div>
155178
);
156179
}

src/progress.jsx

Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
import React from "react/addons";
2+
import Base from "./base";
3+
import Radium from "radium";
4+
5+
const animations = {
6+
pacmanTopFrames: Radium.keyframes({
7+
"0%": {transform: "rotateZ(0deg)"},
8+
"100%": {transform: "rotateZ(-30deg)"}
9+
}),
10+
pacmanBottomFrames: Radium.keyframes({
11+
"0%": {transform: "rotateZ(0deg)"},
12+
"100%": {transform: "rotateZ(30deg)"}
13+
}),
14+
pacmanTopFramesBis: Radium.keyframes({
15+
"0%": {transform: "rotateZ(0deg)"},
16+
"100%": {transform: "rotateZ(-30deg)"}
17+
}),
18+
pacmanBottomFramesBis: Radium.keyframes({
19+
"0%": {transform: "rotateZ(0deg)"},
20+
"100%": {transform: "rotateZ(30deg)"}
21+
})
22+
};
23+
24+
@Radium
25+
class Progress extends Base {
26+
render() {
27+
let style = this.context.styles.progress;
28+
let markup;
29+
switch (this.props.type) {
30+
case "none":
31+
return false;
32+
case "pacman":
33+
style = style.pacman;
34+
markup = (
35+
<div>
36+
<div style={[style.pacman, this.getPointPosition(this.props.currentSlide)]} >
37+
<div style={[style.pacmanTop, this.getPacmanStyle("Top")]} />
38+
<div style={[style.pacmanBottom, this.getPacmanStyle("Bottom")]} />
39+
</div>
40+
{this.props.items.map((item, i) => {
41+
return (<div style={[style.point, this.getPointStyle(i)]}
42+
key={"presentation-progress-" + i} />);
43+
})}
44+
</div>
45+
);
46+
break;
47+
case "number":
48+
style = style.number;
49+
markup = (
50+
<div>{this.props.currentSlide + 1} / {this.props.items.length}</div>
51+
);
52+
break;
53+
case "bar":
54+
style = style.bar;
55+
markup = (
56+
<div style={[style.bar, this.getWidth()]} />
57+
);
58+
break;
59+
default:
60+
return false;
61+
}
62+
return (
63+
<div style={[this.getStyles()]}>
64+
<div style={[style.container]}>
65+
{markup}
66+
</div>
67+
</div>
68+
);
69+
}
70+
71+
getWidth() {
72+
return {
73+
width: (100 * this.props.currentSlide / (this.props.items.length - 1)) + "%"
74+
};
75+
}
76+
77+
getPacmanStyle(side) {
78+
const animationName = "pacman" + side + "Frames" + (this.props.currentSlide % 2 ? "" : "Bis");
79+
return {
80+
animation: animations[animationName] + " 0.12s linear 10 alternate both"
81+
};
82+
}
83+
84+
getPointPosition(i) {
85+
return {
86+
top: "-20px",
87+
left: (5 + 20 * (i - this.props.items.length / 2)) + "px"
88+
};
89+
}
90+
91+
getPointStyle(i) {
92+
const style = this.getPointPosition(i);
93+
if (this.props.currentSlide >= i) {
94+
style.opacity = 0;
95+
}
96+
97+
return style;
98+
}
99+
100+
}
101+
102+
Progress.propTypes = {
103+
items: React.PropTypes.array,
104+
currentSlide: React.PropTypes.number,
105+
type: React.PropTypes.oneOf(["pacman", "bar", "number", "none"])
106+
};
107+
108+
Progress.contextTypes = {
109+
styles: React.PropTypes.object
110+
};
111+
112+
export default Progress;

src/slide.jsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ const Slide = React.createClass({
1919
propTypes: {
2020
align: React.PropTypes.string,
2121
presenterStyle: React.PropTypes.object,
22-
children: React.PropTypes.node
22+
children: React.PropTypes.node,
23+
notes: React.PropTypes.string
2324
},
2425
contextTypes: {
2526
styles: React.PropTypes.object,

src/transitions.jsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ export default {
169169
getTransitionStyles() {
170170
let transformValue = "";
171171
let styles = {
172-
zIndex: this.state.z || ""
172+
zIndex: this.state.z
173173
};
174174
if (this.props.transition.indexOf("fade") !== -1) {
175175
styles = assign(styles, {
@@ -181,6 +181,8 @@ export default {
181181
}
182182
if (this.props.transition.indexOf("slide") !== -1) {
183183
transformValue += " translate3d(" + this.getTweeningValue("left") + "%, 0, 0)";
184+
} else {
185+
transformValue += " translate3d(0px, 0px, 0px)";
184186
}
185187
if (this.props.transition.indexOf("spin") !== -1) {
186188
transformValue += " rotateY(" + this.getTweeningValue("x") + "deg)";

themes/default/index.css

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,12 @@
11
.spectacle-slide {
22
-webkit-transform-origin: center center;
33
transform-origin: center center;
4-
5-
-webkit-transform-style: preserve-3d;
6-
transform-style: preserve-3d;
74
}
85

96
/* Firefox */
107

118
_:-moz-tree-row(hover), .spectacle-deck {
12-
transform: perspective(1000px);
9+
perspective: 1000px;
1310
}
1411

1512
_:-moz-tree-row(hover), ul .appear {

0 commit comments

Comments
 (0)