mirror of
https://github.com/naturalcrit/homebrewery.git
synced 2026-01-01 10:52:46 +00:00
Editor and renderer redraw when you resize the browser
This commit is contained in:
@@ -23,11 +23,20 @@ var BrewRenderer = React.createClass({
|
||||
height : 0,
|
||||
|
||||
componentDidMount: function() {
|
||||
this.updateSize();
|
||||
window.addEventListener("resize", this.updateSize);
|
||||
},
|
||||
componentWillUnmount: function() {
|
||||
window.removeEventListener("resize", this.updateSize);
|
||||
},
|
||||
|
||||
updateSize : function() {
|
||||
this.setState({
|
||||
height : this.refs.main.parentNode.clientHeight,
|
||||
isMounted : true
|
||||
});
|
||||
},
|
||||
|
||||
handleScroll : function(e){
|
||||
this.setState({
|
||||
viewablePageNumber : Math.floor(e.target.scrollTop / PAGE_HEIGHT)
|
||||
|
||||
@@ -28,9 +28,19 @@ var Editor = React.createClass({
|
||||
},
|
||||
|
||||
componentDidMount: function() {
|
||||
this.updateEditorSize();
|
||||
window.addEventListener("resize", this.updateEditorSize);
|
||||
},
|
||||
componentWillUnmount: function() {
|
||||
window.removeEventListener("resize", this.updateEditorSize);
|
||||
},
|
||||
|
||||
updateEditorSize : function() {
|
||||
var paneHeight = this.refs.main.parentNode.clientHeight;
|
||||
paneHeight -= this.refs.snippetBar.clientHeight + 1;
|
||||
this.refs.codeEditor.codeMirror.setSize(null, paneHeight);
|
||||
|
||||
this.refs.codeEditor.updateSize();
|
||||
},
|
||||
|
||||
handleTextChange : function(text){
|
||||
@@ -48,10 +58,6 @@ var Editor = React.createClass({
|
||||
this.refs.codeEditor.setCursorPosition(this.cursorPosition.line, this.cursorPosition.ch + injectText.length);
|
||||
},
|
||||
|
||||
//Called when there are changes to the editor's dimensions
|
||||
update : function(){
|
||||
this.refs.codeEditor.updateSize();
|
||||
},
|
||||
|
||||
renderSnippetGroups : function(){
|
||||
return _.map(Snippets, (snippetGroup)=>{
|
||||
|
||||
@@ -52,14 +52,7 @@ var EditPage = React.createClass({
|
||||
},
|
||||
savedBrew : null,
|
||||
|
||||
test : ()=>{
|
||||
|
||||
},
|
||||
|
||||
componentDidMount: function(){
|
||||
|
||||
console.log('getting here');
|
||||
|
||||
this.debounceSave = _.debounce(this.save, SAVE_TIMEOUT);
|
||||
window.onbeforeunload = ()=>{
|
||||
if(this.state.isSaving || this.state.isPending){
|
||||
|
||||
Reference in New Issue
Block a user