Skip to content

Instantly share code, notes, and snippets.

@shershen08
Created January 20, 2015 17:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shershen08/7b8aad951230267b14e4 to your computer and use it in GitHub Desktop.
Save shershen08/7b8aad951230267b14e4 to your computer and use it in GitHub Desktop.
// Movable grid line
// ------------------
// remove on dblclick, several lines possible
jQuery('<div/>').prependTo('body')
.css({"position":"absolute","width": 1,"height":jQuery('body').css('height'),"background":"#f00","left":30,"z-index":10000, 'cursor':'pointer'})
.dblclick(function() {jQuery(this).remove();})
.hover(function(){
var lineId = (new Date()).getTime().toString().substr(8);
jQuery(this).addClass('grid-line').attr('id', 'grid'+lineId).css({"width": 2});
},function(){ jQuery(this).css({"width": 1}); })
.mousedown(function(e) {
var gridLine = jQuery(this); gridLine.css({"cursor": "col-resize"});
jQuery(document).one('mouseup', function(e) {gridLine.css({"cursor": "pointer"}).css({"left": e.clientX});});
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment