-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Introduce ReactSWFCompat to support IE8-9
- Loading branch information
Showing
11 changed files
with
185 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
/*! react-swf v1.0.3 | @syranide | MIT license */ | ||
|
||
'use strict'; | ||
|
||
var React = require('react'); | ||
var ReactDOM = require('react-dom'); | ||
var ReactDOMServer = require('react-dom/server'); | ||
var ReactSWF = require('react-swf'); | ||
var PropTypes = React.PropTypes; | ||
|
||
function ReactSWFCompat(props) { | ||
React.Component.call(this, props); | ||
|
||
var that = this; | ||
this._containerRefCallback = function(c) { | ||
that._container = c; | ||
}; | ||
this._swfRefCallback = function(c) { | ||
that._swf = c; | ||
}; | ||
} | ||
|
||
ReactSWFCompat.prototype = Object.create(React.Component.prototype); | ||
ReactSWFCompat.prototype.constructor = ReactSWFCompat; | ||
Object.assign(ReactSWFCompat, React.Component); | ||
|
||
ReactSWFCompat.propTypes = { | ||
container: PropTypes.element.isRequired | ||
}; | ||
|
||
ReactSWFCompat.prototype._createSWFElement = function() { | ||
var swfProps = Object.assign({}, this.props); | ||
swfProps.container = undefined; | ||
swfProps.movie = swfProps.src; | ||
swfProps.ref = this._swfRefCallback; | ||
|
||
return React.createElement(ReactSWF, swfProps); | ||
}; | ||
|
||
ReactSWFCompat.prototype.getFPDOMNode = function() { | ||
return this._swf.getFPDOMNode(); | ||
}; | ||
|
||
ReactSWFCompat.prototype.componentDidMount = function() { | ||
var swfElement = this._createSWFElement(); | ||
this._container.innerHTML = ReactDOMServer.renderToString(swfElement); | ||
ReactDOM.render(swfElement, this._container); | ||
}; | ||
|
||
ReactSWFCompat.prototype.componentDidUpdate = function() { | ||
var swfElement = this._createSWFElement(); | ||
ReactDOM.render(swfElement, this._container); | ||
}; | ||
|
||
ReactSWFCompat.prototype.render = function() { | ||
var containerProps = { | ||
ref: this._containerRefCallback | ||
}; | ||
|
||
return React.cloneElement(this.props.container, containerProps, null); | ||
}; | ||
|
||
module.exports = ReactSWFCompat; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
/*! react-swf v1.0.3 | @syranide | MIT license */ | ||
|
||
(function(root, factory) { | ||
if (typeof define === 'function' && define.amd) { | ||
define(['react', 'react-dom', 'react-dom/server', 'react-swf'], factory); | ||
} else if (typeof exports === 'object') { | ||
module.exports = factory(require('react'), require('react-dom'), require('react-dom-server'), require('react-swf')); | ||
} else { | ||
root.ReactSWFCompat = factory(root.React, root.ReactDOM, root.ReactDOMServer, root.ReactSWF); | ||
} | ||
}(this, function(React, ReactDOM, ReactDOMServer, ReactSWF) { | ||
'use strict'; | ||
|
||
var PropTypes = React.PropTypes; | ||
|
||
function ReactSWFCompat(props) { | ||
React.Component.call(this, props); | ||
|
||
var that = this; | ||
this._containerRefCallback = function(c) { | ||
that._container = c; | ||
}; | ||
this._swfRefCallback = function(c) { | ||
that._swf = c; | ||
}; | ||
} | ||
|
||
ReactSWFCompat.prototype = Object.create(React.Component.prototype); | ||
ReactSWFCompat.prototype.constructor = ReactSWFCompat; | ||
Object.assign(ReactSWFCompat, React.Component); | ||
|
||
ReactSWFCompat.propTypes = { | ||
container: PropTypes.element.isRequired | ||
}; | ||
|
||
ReactSWFCompat.prototype._createSWFElement = function() { | ||
var swfProps = Object.assign({}, this.props); | ||
swfProps.container = undefined; | ||
swfProps.movie = swfProps.src; | ||
swfProps.ref = this._swfRefCallback; | ||
|
||
return React.createElement(ReactSWF, swfProps); | ||
}; | ||
|
||
ReactSWFCompat.prototype.getFPDOMNode = function() { | ||
return this._swf.getFPDOMNode(); | ||
}; | ||
|
||
ReactSWFCompat.prototype.componentDidMount = function() { | ||
var swfElement = this._createSWFElement(); | ||
this._container.innerHTML = ReactDOMServer.renderToString(swfElement); | ||
ReactDOM.render(swfElement, this._container); | ||
}; | ||
|
||
ReactSWFCompat.prototype.componentDidUpdate = function() { | ||
var swfElement = this._createSWFElement(); | ||
ReactDOM.render(swfElement, this._container); | ||
}; | ||
|
||
ReactSWFCompat.prototype.render = function() { | ||
var containerProps = { | ||
ref: this._containerRefCallback | ||
}; | ||
|
||
return React.cloneElement(this.props.container, containerProps, null); | ||
}; | ||
|
||
return ReactSWFCompat; | ||
})); |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.