Skip to content

Instantly share code, notes, and snippets.

@Imater
Created August 26, 2014 11:33
Show Gist options
  • Save Imater/d827739bb33178a688e6 to your computer and use it in GitHub Desktop.
Save Imater/d827739bb33178a688e6 to your computer and use it in GitHub Desktop.
First draft of resize html windows on layout
$(".resize-handle").on "mousedown", (e)->
left = $(this).prev('.layout-col')
right = $(this).next('.layout-col')
windowWidth = $(window).width()
oldLeft = left.width()/windowWidth*100;
oldRight = right.width()/windowWidth*100;
oldX = e.clientX
console.info 'start', oldLeft, oldRight
onMouseMove = (e) ->
offset = oldX - e.clientX
console.info e.offsetX
newLeft = oldLeft - ( offset )/windowWidth*100
newRight = oldRight + ( offset )/windowWidth*100
left.width( newLeft + '%' )
right.width( newRight + '%' )
onMouseUp = ->
$(window.document).off("mousemove", onMouseMove).off("mouseup", onMouseUp)
console.info 'off'
$(window.document).on "mousemove", onMouseMove
$(window.document).on "mouseup", onMouseUp
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment