Skip to content

Commit 463f601

Browse files
committed
Merge pull request #36 from mathieudutour/master
remove fid from Appear
2 parents d5f6e3c + 7c73d4b commit 463f601

File tree

3 files changed

+10
-8
lines changed

3 files changed

+10
-8
lines changed

README.markdown

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ The element tags are the bread and butter of your slide content. Most of these t
216216
217217
####\<Appear />
218218
219-
This tag does not extend from Base. It's special. Wrapping elements in the appear tag makes them appear/disappear in order in response to navigation. The Appear tag requires adding `fid` tags that are unique within a given slide. This requirement will go away in React 0.14.
219+
This tag does not extend from Base. It's special. Wrapping elements in the appear tag makes them appear/disappear in order in response to navigation.
220220
221221
####\<BlockQuote />, \<Quote/> and \<Cite /> (Base)
222222

src/appear.jsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,15 @@ const Appear = React.createClass({
2121
},
2222
componentDidMount() {
2323
this.context.flux.stores.SlideStore.listen(this._storeChange);
24-
const slide = this.context.slide;
2524
},
2625
componentWillUnmount() {
2726
this.context.flux.stores.SlideStore.unlisten(this._storeChange);
2827
},
2928
_storeChange(state) {
3029
const slide = this.context.slide;
30+
const fragment = React.findDOMNode(this.refs.fragment);
3131
const key = _.findKey(state.fragments[slide], {
32-
"id": this.props.fid
32+
"id": parseInt(fragment.dataset.fid)
3333
});
3434
if (slide in state.fragments && state.fragments[slide].hasOwnProperty(key)) {
3535
this.setState({
@@ -52,7 +52,7 @@ const Appear = React.createClass({
5252
opacity: this.getTweeningValue("opacity")
5353
};
5454
return (
55-
<div style={styles} className="fragment" data-fid={this.props.fid}>
55+
<div style={styles} className="fragment" ref="fragment">
5656
{this.props.children}
5757
</div>
5858
);

src/slide.jsx

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ const Slide = React.createClass({
2020
align: React.PropTypes.string,
2121
presenterStyle: React.PropTypes.object,
2222
children: React.PropTypes.node,
23-
notes: React.PropTypes.string
23+
notes: React.PropTypes.string,
24+
slideIndex: React.PropTypes.number
2425
},
2526
contextTypes: {
2627
styles: React.PropTypes.object,
@@ -51,13 +52,14 @@ const Slide = React.createClass({
5152
const slide = React.findDOMNode(this.refs.slide);
5253
const frags = slide.querySelectorAll(".fragment");
5354
if (frags && frags.length) {
54-
Array.prototype.slice.call(frags, 0).forEach((frag) => {
55+
Array.prototype.slice.call(frags, 0).forEach((frag, i) => {
56+
frag.dataset.fid = i;
5557
this.context.flux.actions.SlideActions.addFragment({
5658
slide: this.props.slideIndex,
57-
id: frag.dataset.fid,
59+
id: i,
5860
visible: false
5961
});
60-
})
62+
});
6163
}
6264
window.addEventListener("load", this.setZoom);
6365
window.addEventListener("resize", this.setZoom);

0 commit comments

Comments
 (0)