Skip to content

Commit

Permalink
Re-use ref callback
Browse files Browse the repository at this point in the history
  • Loading branch information
syranide committed Aug 11, 2015
1 parent 99e3949 commit 7f7c4ec
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 10 deletions.
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "react-swf",
"version": "0.12.1",
"version": "0.12.2",
"license": "MIT",
"description": "Shockwave Flash Player component for React",
"authors": ["Andreas Svensson <[email protected]>"],
Expand Down
2 changes: 1 addition & 1 deletion npm-react-swf/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "react-swf",
"version": "0.12.1",
"version": "0.12.2",
"license": "MIT",
"description": "Shockwave Flash Player component for React",
"author": "Andreas Svensson <[email protected]>",
Expand Down
9 changes: 7 additions & 2 deletions npm-react-swf/react-swf.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*! react-swf v0.12.1 | @syranide | MIT license */
/*! react-swf v0.12.2 | @syranide | MIT license */

'use strict';

Expand Down Expand Up @@ -187,6 +187,11 @@ function isFPVersionSupported(versionString) {
function ReactSWF(props) {
React.Component.call(this, props);

var that = this;
this._refCallback = function(c) {
that._node = c;
};

// The only way to change Flash parameters or reload the movie is to update
// the key of the ReactSWF element. This unmounts the previous instance and
// reloads the movie. Store initial values to keep the DOM consistent.
Expand Down Expand Up @@ -322,7 +327,7 @@ ReactSWF.prototype.render = function() {
// we must leave it up to the user.

var objectProps = {
ref: function(c) { that._node = c; },
ref: this._refCallback,
children: [],
type: mimeTypeFP,
data: state.src,
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "react-swf",
"version": "0.12.1",
"version": "0.12.2",
"license": "MIT",
"description": "Shockwave Flash Player component for React",
"author": "Andreas Svensson <[email protected]>",
Expand Down
10 changes: 7 additions & 3 deletions react-swf.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*! react-swf v0.12.1 | @syranide | MIT license */
/*! react-swf v0.12.2 | @syranide | MIT license */

(function(root, factory) {
if (typeof define === 'function' && define.amd) {
Expand Down Expand Up @@ -194,6 +194,11 @@
function ReactSWF(props) {
React.Component.call(this, props);

var that = this;
this._refCallback = function(c) {
that._node = c;
};

// The only way to change Flash parameters or reload the movie is to update
// the key of the ReactSWF element. This unmounts the previous instance and
// reloads the movie. Store initial values to keep the DOM consistent.
Expand Down Expand Up @@ -320,7 +325,6 @@
};

ReactSWF.prototype.render = function() {
var that = this;
var props = this.props;
var state = this.state;

Expand All @@ -329,7 +333,7 @@
// we must leave it up to the user.

var objectProps = {
ref: function(c) { that._node = c; },
ref: this._refCallback,
children: [],
type: mimeTypeFP,
data: state.src,
Expand Down
4 changes: 2 additions & 2 deletions react-swf.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 7f7c4ec

Please sign in to comment.