jQuery drag-and-drop issue without jQuery UI -


i trying drag-and-drop without using jquery ui. (200kb load)

i have 2 problems:

  1. i not sure how snap dragged element element. know in jquery ui can provide option 'snap' not sure how in plain jquery.

  2. where can change cursor pointer icon when drag element?

i have following code:

var dragging =null;  obj = $('table td');  $(obj).click(function(e){     if(dragging){         dragging = null;     }     else{         dragging = $(e.target);     } })  $(document.body).mousemove(function(e){     var el_w = $(obj).width();     var el_h = $(obj).height();     if (dragging) {         dragging.offset({             top : e.pagey-el_h/2,             left : e.pagex-el_w/2         })     } }) 

i have searched google of results suggest jquery ui... :(

custom build

you can download custom version of jquery ui. follow link, go bottom, , click download.

draggable only

the size 32kb. modern web servers gzip file, result in 8.66kb in transfer. can combined other files reduce number of network requests.

alternative

the amazing chris coyer wrote small plugin mimics $.draggable jquery ui.

note: have modify code kind of snapping, etc.

draggable without jquery ui

if minified closure compiler, file size 0.769kb or 0.353kb gzipped.

all statistics derived online closure compiler


Comments

Popular posts from this blog

c++ - Creating new partition disk winapi -

Android Prevent Bluetooth Pairing Dialog -

php - joomla get content in onBeforeCompileHead function -