Skip to content

Commit

Permalink
Merge branch 'master' into buyers-guide-homepage
Browse files Browse the repository at this point in the history
  • Loading branch information
alanmoo committed Oct 17, 2018
2 parents fe139d6 + 3c23b19 commit 9f7da60
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 9 deletions.
22 changes: 15 additions & 7 deletions source/js/buyers-guide/components/creepometer/creepometer.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,15 @@ export default class Creepometer extends React.Component {

slideMove(e) {
if (this.state.isHandleGrabbed) {
let clientX = e.nativeEvent.clientX;
let sliderLeftEdgeX = this.sliderElement.getBoundingClientRect().left;
let offset = Math.floor(clientX - sliderLeftEdgeX);
let clientX, sliderLeftEdgeX, offset;

if (e.nativeEvent.type === `touchmove`){
clientX = e.nativeEvent.touches[0].pageX;
} else {
clientX = e.nativeEvent.clientX;
}
sliderLeftEdgeX = this.sliderElement.getBoundingClientRect().left;
offset = Math.floor(clientX - sliderLeftEdgeX);

this.setState({
handleOffset: offset,
Expand Down Expand Up @@ -81,10 +87,12 @@ export default class Creepometer extends React.Component {

return (
<div class="creepometer">
<div className="slider" ref={this.setSliderRef} onMouseLeave={this.slideStop} onMouseMove={this.slideMove} onMouseDown={this.slideStart} onMouseUp={this.slideStop}>
<div className="h6-heading copy copy-left">Not creepy</div>
<div className="handle" style={{background: `url("${this.framePath}sprite-resized-64-colors.png") 0 ${pxOffset}px / 70px auto, #f2b946`, left: `${handleX}px`}}></div>
<div className="h6-heading copy copy-right">Super creepy</div>
<div class="slider-container p-2" onMouseLeave={this.slideStop} onMouseUp={this.slideStop}>
<div className="slider" ref={this.setSliderRef} onMouseMove={this.slideMove} onMouseDown={this.slideStart} onMouseUp={this.slideStop}>
<div className="h6-heading copy copy-left">Not creepy</div>
<div className="handle" onTouchStart={this.slideStart} onTouchMove={this.slideMove} onTouchEnd={this.slideStop} style={{background: `url("${this.framePath}sprite-resized-64-colors.png") 0 ${pxOffset}px / 70px auto, #f2b946`, left: `${handleX}px`}}></div>
<div className="h6-heading copy copy-right">Super creepy</div>
</div>
</div>
</div>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,12 @@
}

.handle {
border-radius: 50%;
cursor: grab;
height: 70px;
position: absolute;
user-select: none;
width: 70px;
height: 70px;
border-radius: 50%;
z-index: 1;
}
}

0 comments on commit 9f7da60

Please sign in to comment.