473,382 Members | 1,329 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

scrollable div when dragging

178 100+
Does anyone know of a good tutorial or can point me in the right direction in relation to this problem?

I have a div with objects inside it that can be dragged and dropped. I want to set the properties of the div so when I drag an object to the right side edge the window will scroll right.
Jul 17 '08 #1
4 1472
hsriat
1,654 Expert 1GB
If you drag something out if the window, the window automatically scrolls to that side. What exactly are you trying to achieve?
Jul 17 '08 #2
rnd me
427 Expert 256MB
you will have to check to location in the drag and drop mouseup routine and either
scroll the window, or push the dragger tag back to say, screen.availWidth - parseInt(elm.style.width)
Jul 17 '08 #3
cleary1981
178 100+
the window does scroll automatically but only a little. The object being dragged goes out of view and you have to scroll over and pick he object up again. I want the div to keep the object in view and keep scrolling until I drop the object. Does that make sense?
Jul 17 '08 #4
cleary1981
178 100+
heres the drag drop code im using

Expand|Select|Wrap|Line Numbers
  1. var mousex = 0;
  2. var mousey = 0;
  3. var grabx = 0;
  4. var graby = 0;
  5. var orix = 0;
  6. var oriy = 0;
  7. var elex = 0;
  8. var eley = 0;
  9. var algor = 0;
  10.  
  11. var dragobj = null;
  12.  
  13. function falsefunc() { return false; } // used to block cascading events
  14.  
  15. function init()
  16. {
  17.   document.onmousemove = update; // update(event) implied on NS, update(null) implied on IE
  18.   update();
  19. }
  20.  
  21. function getMouseXY(e) // works on IE6,FF,Moz,Opera7
  22.   if (!e) e = window.event; // works on IE, but not NS (we rely on NS passing us the event)
  23.  
  24.   if (e)
  25.   { 
  26.     if (e.pageX || e.pageY)
  27.     { // this doesn't work on IE6!! (works on FF,Moz,Opera7)
  28.       mousex = e.pageX;
  29.       mousey = e.pageY;
  30.       algor = '[e.pageX]';
  31.       if (e.clientX || e.clientY) algor += ' [e.clientX] '
  32.     }
  33.     else if (e.clientX || e.clientY)
  34.     { // works on IE6,FF,Moz,Opera7
  35.       mousex = e.clientX + document.body.scrollLeft;
  36.       mousey = e.clientY + document.body.scrollTop;
  37.       algor = '[e.clientX]';
  38.       if (e.pageX || e.pageY) algor += ' [e.pageX] '
  39.     }  
  40.   }
  41. }
  42.  
  43. function update(e)
  44. {
  45.   getMouseXY(e); // NS is passing (event), while IE is passing (null)
  46.  
  47.   document.getElementById('xpos').value = elex;
  48.   document.getElementById('ypos').value = eley;
  49.   document.getElementById('object').value = ss;
  50. }
  51.  
  52. function grab(context, mod_name)
  53. {
  54.   document.onmousedown = falsefunc; // in NS this prevents cascading of events, thus disabling text selection
  55.   dragobj = context;
  56.   ss = context.Class;
  57.   dragobj.style.zIndex = 10; // move it to the top
  58.   document.onmousemove = drag;
  59.   document.onmouseup = drop;
  60.   grabx = mousex;
  61.   graby = mousey;
  62.   elex = orix = dragobj.offsetLeft;
  63.   eley = oriy = dragobj.offsetTop;
  64.   update();
  65. }
  66.  
  67. function drag(e) // parameter passing is important for NS family 
  68. {
  69.   if (dragobj)
  70.   {
  71.     elex = orix + (mousex-grabx);
  72.     eley = oriy + (mousey-graby);
  73.     dragobj.style.position = "absolute";
  74.     dragobj.style.left = (elex).toString(10) + 'px';
  75.     dragobj.style.top  = (eley).toString(10) + 'px';
  76.   }
  77.   update(e);
  78.   return false; // in IE this prevents cascading of events, thus text selection is disabled
  79. }
  80.  
  81. function drop()
  82. {
  83.   if (dragobj)
  84.   {
  85.     dragobj.style.zIndex = 0;
  86.     dragobj = null;
  87.   }
  88.   update();
  89.   document.onmousemove = update;
  90.   document.onmouseup = null;
  91.   document.onmousedown = null;   // re-enables text selection on NS
  92. }
  93.  
Jul 17 '08 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

7
by: Matt Kruse | last post by:
This is a typical layout, but I have specific requirements. I'm trying to figure out a) if it's possible to meet the requirements and b) if so, how. +---------------+ | header |...
25
by: Michael Schuerig | last post by:
I'm trying to do something seemingly very simple, but it's brought me close to crushing my head on the keyboard. All I want is a table where the head row is fixed and the body columns below are...
0
by: 4.spam | last post by:
Hello. W2K, v8.2.1, jcc driver I am trying to get scrollable result set from SQL stored procedure in my java application using jcc driver. --- CallableStatement cs = conn.prepareCall (...
5
by: Brian Henry | last post by:
Hello, I want to make a control that has a scrollable Gantt type display (not really one but will look similar to one) this is going to be custom drawn (i already have the drawing procedure...
1
by: Keimo Repo | last post by:
Hello I would need some advice, even just speculations... A customer of ours insists on a couple of customer specific design features for our existing multi-customer web application: - A...
2
by: Ben H | last post by:
Hello all I'm using a listview in my app but I want to scroll the listview programatically as I hate the look of the standard scrollbar. So, the listview is scrolled programatically using...
3
by: RMuthuKumaran | last post by:
When we are trying to execute scrollable resultset APIs (rs.last etc.,) we get the following error. (Database version: UDB 7. on Windows. Driver: Type 4.) This method should only be called on...
0
by: Rune Jacobsen | last post by:
Hi all, In my project I have a control (described in an earlier post) which basically consists of three "subcontrols": One big area where the vital data is displayed (scrollable, since it will...
1
by: since | last post by:
I figured I would post my solution to the following. Resizable column tables. Search and replace values in a table. (IE only) Scrollable tables. Sortable tables. It is based on a lot...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.