Closed nsaje closed 8 years ago
Ah, this partially addresses #119, sorry I only just saw this. Can you see a way to trigger this on pane-resize (probably after some inactivity delay)?
Sure, I'll look into it, just have to find a way to listen to a pane resize event or something such.
On Fri, Feb 12, 2016, 04:28 Ollie Ford notifications@github.com wrote:
Ah, this partially addresses #119 https://github.com/izuzak/atom-pdf-view/issues/119, sorry I only just saw this. Can you see a way to trigger this on pane-resize (probably after some inactivity delay)?
— Reply to this email directly or view it on GitHub https://github.com/izuzak/atom-pdf-view/pull/112#issuecomment-183165319.
Hm, I've had a look myself, I'm not sure there is anything at the moment. I couldn't see anything in the API, and the resize handler doesn't seem to emit anything:
class PaneResizeHandleElement extends HTMLElement
# ...
resizePane: ({clientX, clientY, which}) ->
return @resizeStopped() unless which is 1
return @resizeStopped() unless @previousSibling? and @nextSibling?
if @isHorizontal
totalWidth = @previousSibling.clientWidth + @nextSibling.clientWidth
#get the left and right width after move the resize view
leftWidth = clientX - @previousSibling.getBoundingClientRect().left
leftWidth = @fixInRange(leftWidth, 0, totalWidth)
rightWidth = totalWidth - leftWidth
# set the flex grow by the ratio of left width and right width
# to change pane width
@setFlexGrow(leftWidth, rightWidth)
else
totalHeight = @previousSibling.clientHeight + @nextSibling.clientHeight
topHeight = clientY - @previousSibling.getBoundingClientRect().top
topHeight = @fixInRange(topHeight, 0, totalHeight)
bottomHeight = totalHeight - topHeight
@setFlexGrow(topHeight, bottomHeight)
resizeStopped: ->
document.removeEventListener 'mousemove', @resizePane
document.removeEventListener 'mouseup', @resizeStopped
If I haven't missed anything, perhaps the best would be to fire off some resized
event in resizeStopped
?
Thanks for opening a pull request, @nsaje :sparkles:, and thanks for the comments, @OJFord :bow:
My recommendation would be to keep this pull request to one thing and to the fit-on-resize ability in a different pull request. For the fit-on-resize ability, I think you can hook into this part which is already listening on the window's resize.
Other than that -- I just had one minor comment. @nsaje -- if you agree with that, I think we can get this merged after you push an update. Let me know :bow:
@izuzak Here you go, let me know if you need anything else fixed :smile:
Thanks for this, @nsaje :tophat:
Adds a Fit to width option in the config. If set, document will be scaled to the current buffer on first render.
BTW, is there any better way to get buffer width than
this[0].clientWidth
, or is that alright? I couldn't find any other way.closes #73