Created
August 26, 2014 11:33
-
-
Save Imater/d827739bb33178a688e6 to your computer and use it in GitHub Desktop.
First draft of resize html windows on layout
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$(".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