Skip to content

Commit

Permalink
mix minor errors on component updates
Browse files Browse the repository at this point in the history
  • Loading branch information
btzr-io committed Nov 15, 2019
1 parent 00663ee commit 5ec5531
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 26 deletions.
11 changes: 9 additions & 2 deletions src/components/render.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,15 @@ class CanvasRender extends Component {
}

getTargetZoom = (scale = 1) => {
const { viewport } = this.viewer
return viewport.imageToViewportZoom(scale)
let zooms = []
const { viewport, world } = this.viewer
const count = world.getItemCount()

for (let i = 0; i < count; i++) {
zooms[i] = world.getItemAt(i).imageToViewportZoom(scale)
}

return Math.max(zooms)
}

updateZoomLimits = () => {
Expand Down
25 changes: 1 addition & 24 deletions src/components/slider/sliderRail.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,30 +13,7 @@ const railStyle = {
}

const SliderRail = ({ activeHandleID, getEventData, getRailProps }) => {
const [value, setValue] = useState(null)
const [percent, setPercent] = useState(null)

const onMouseEnter = () => {
document.addEventListener('mousemove', onMouseMove)
}

const onMouseLeave = () => {
setValue(null)
setPercent(null)
document.removeEventListener('mousemove', onMouseMove)
}

const onMouseMove = e => {
if (activeHandleID) {
setValue(null)
setPercent(null)
} else {
setValue(getEventData(e).value)
setPercent(getEventData(e).percent)
}
}

return <div style={railStyle} {...getRailProps({ onMouseEnter, onMouseLeave })} />
return <div style={railStyle} {...getRailProps()} />
}

SliderRail.propTypes = {
Expand Down

0 comments on commit 5ec5531

Please sign in to comment.