Skip to content

Instantly share code, notes, and snippets.

@nrako
Created July 20, 2016 22:57

Revisions

  1. nrako created this gist Jul 20, 2016.
    34 changes: 34 additions & 0 deletions index.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,34 @@
    // Welcome! require() some modules from npm (like you were using browserify)
    // and then hit Run Code to run your code on the right side.
    // Modules get downloaded from browserify-cdn and bundled in your browser.
    var React = require('react')
    var ReactDOM = require('react-dom')
    var Resizable = require('react-component-resizable').default

    var WindowResizable = React.createClass({

    getInitialState: function(){
    return {
    width: 0,
    height: 0
    };
    },

    render: function(){
    console.log(this.state);
    var width = this.state.width, height = this.state.height;
    var div = React.createElement('div', {className: 'fill'}, width + 'x' + height);
    return React.createElement(Resizable, {onResize: this.onResize}, div);
    },

    onResize: function(resizeAttributes){
    var width = resizeAttributes.width,
    height = resizeAttributes.height;

    this.setState({width: width, height: height});
    }

    });


    ReactDOM.render(React.createElement(WindowResizable), document.getElementById('example'));
    17 changes: 17 additions & 0 deletions minified.js
    17 additions, 0 deletions not shown because the diff is too large. Please use a local Git client to view these changes.
    9 changes: 9 additions & 0 deletions package.json
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,9 @@
    {
    "name": "requirebin-sketch",
    "version": "1.0.0",
    "dependencies": {
    "react": "15.2.1",
    "react-dom": "15.2.1",
    "react-component-resizable": "1.0.2"
    }
    }
    2 changes: 2 additions & 0 deletions page-body.html
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,2 @@
    <!-- contents of this file will be placed inside the <body> -->
    <div id="example"></div>
    12 changes: 12 additions & 0 deletions page-head.html
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,12 @@
    <!-- contents of this file will be placed inside the <head> -->
    <style type="text/css">
    body, html{
    height: 100%;
    }
    div{
    height: 100%;
    }
    .fill{
    height: 100%;
    }
    </style>
    1 change: 1 addition & 0 deletions requirebin.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1 @@
    made with [requirebin](http://requirebin.com)