0
0
mirror of https://github.com/naturalcrit/homebrewery.git synced 2025-12-26 18:12:40 +00:00

Editor and renderer redraw when you resize the browser

This commit is contained in:
Scott Tolksdorf
2016-08-20 13:26:48 -04:00
parent ef8784ccf2
commit 888d3faa4c
4 changed files with 22 additions and 11 deletions

View File

@@ -7,6 +7,9 @@
- If you visit a deleted brew, it will now remove it from your recent list. (Thanks u/sIllverback!)
- Improved parsing of embedded html text in brews. (Thanks u/com-charizard!)
- Added in a new coverpage snippet
- Homebrewery will now try and onsert a good title for your brew if you don't provide one
- Homebrewery now re-renders properly when you zoom
### Friday, 29/07/2016 - v2.2.7
- Adding in descriptive note blocks. (Thanks calculuschild!)

View File

@@ -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)

View File

@@ -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)=>{

View File

@@ -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){