Skip to content

Commit

Permalink
Affix, sadly still using jQuery for now
Browse files Browse the repository at this point in the history
  • Loading branch information
dumbmatter committed Aug 24, 2016
1 parent 3b38bc7 commit d2ea621
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 26 deletions.
1 change: 0 additions & 1 deletion TODO
@@ -1,7 +1,6 @@
REACT

Live
affix plays
going to live_game URL should redirect to live if there is no game forthcoming, like it used to

Switch between two leagues directly with forward/back (react to react) and it has the two controllers problem
Expand Down
8 changes: 0 additions & 8 deletions src/css/bbgm.scss
Expand Up @@ -737,14 +737,6 @@ tr.warning > td {
}
}

@media (min-width: 1200px) {
// Widen the fixed sidebar again
.affix-bottom,
.affix {
width: 360px;
}
}

// Large screen sidebar, adapted from Bootstrap docs
.bs-sidenav {
margin-top: 24px;
Expand Down
16 changes: 0 additions & 16 deletions src/js/views/liveGame.js
Expand Up @@ -77,22 +77,6 @@ async function updatePlayByPlay(inputs) {
}*/
}

function uiFirst() {
// Keep plays list always visible
$("#affixPlayByPlay").affix({
offset: {
top: 80,
},
});

// Keep height of plays list equal to window
const playByPlayList = document.getElementById("playByPlayList");
playByPlayList.style.height = `${window.innerHeight - 114}px`;
window.addEventListener("resize", () => {
playByPlayList.style.height = `${window.innerHeight - 114}px`;
});
}

module.exports = bbgmViewReact.init({
id: "liveGame",
get,
Expand Down
23 changes: 22 additions & 1 deletion src/js/views/views/LiveGame.js
@@ -1,4 +1,5 @@
const classNames = require('classnames');
const $ = require('jquery');
const React = require('react');
const bbgmViewReact = require('../../util/bbgmViewReact');
const helpers = require('../../util/helpers');
Expand Down Expand Up @@ -117,6 +118,7 @@ class LiveGame extends React.Component {
}

this.handleSpeedChange = this.handleSpeedChange.bind(this);
this.setPlayByPlayDivHeight = this.setPlayByPlayDivHeight.bind(this);
}

componentWillReceiveProps(nextProps) {
Expand All @@ -131,10 +133,27 @@ class LiveGame extends React.Component {

componentDidMount() {
this.componentIsMounted = true;

// Keep plays list always visible
$(this.affixDiv).affix({
offset: {
top: 80,
},
});

// Keep height of plays list equal to window
this.setPlayByPlayDivHeight();
window.addEventListener("resize", this.setPlayByPlayDivHeight);
}

componentWillUnmount() {
this.componentIsMounted = false;

window.removeEventListener("resize", this.setPlayByPlayDivHeight);
}

setPlayByPlayDivHeight() {
this.playByPlayDiv.style.height = `${window.innerHeight - 114}px`;
}

startLiveGame(events) {
Expand Down Expand Up @@ -273,7 +292,9 @@ class LiveGame extends React.Component {
}
</div>
<div className="col-md-3">
<div id="affixPlayByPlay">
<div ref={c => {
this.affixDiv = c;
}}>
<form>
<label htmlFor="playByPlaySpeed">Play-By-Play Speed:</label>
<input type="range" id="playByPlaySpeed" min="1" max="33" step="1" style={{width: '100%'}} value={this.state.speed} onChange={this.handleSpeedChange} />
Expand Down

0 comments on commit d2ea621

Please sign in to comment.