Hello,
I have a floating div which I drag all over the page. I want to enable
window.scrollBy function when div is dragged close to top or bottom of
the page, so users would drag this div to the very top or bottom of the
long page. However, when my page gets scrolled up or down, the div I
drag with my mouse scrolls with page too, and I no longer hold the div.
I added a functionality to change the top position of the div to be the
same as mouse top position but that does not seem to work well.
Can anyone suggest something for my case? I'd really be grateful. 3 2982
<vu******@gmail .comschreef
Hello,
I have a floating div which I drag all over the page. I want to enable
window.scrollBy function when div is dragged close to top or bottom of
the page, so users would drag this div to the very top or bottom of the
long page. However, when my page gets scrolled up or down, the div I
drag with my mouse scrolls with page too, and I no longer hold the div.
I added a functionality to change the top position of the div to be the
same as mouse top position but that does not seem to work well.
Can anyone suggest something for my case? I'd really be grateful.
Can post an url to an example page? It sounds a tad overcomplicated . I
understand you want to scroll when the window when the object being dragged
gets close to the edge. Is that right? Then you need adjust the position of
the dragged object with the amount that the window scrolls. So instead of
looking at the mouse at this point, look at the distance that the window
travels.
HTH
Ivo http://4umi.com/web/javascript/
Thank you. I'll see if I can post an example.
Ivo wrote:
<vu******@gmail .comschreef
Hello,
I have a floating div which I drag all over the page. I want to enable
window.scrollBy function when div is dragged close to top or bottom of
the page, so users would drag this div to the very top or bottom of the
long page. However, when my page gets scrolled up or down, the div I
drag with my mouse scrolls with page too, and I no longer hold the div.
I added a functionality to change the top position of the div to be the
same as mouse top position but that does not seem to work well.
Can anyone suggest something for my case? I'd really be grateful.
Can post an url to an example page? It sounds a tad overcomplicated . I
understand you want to scroll when the window when the object being dragged
gets close to the edge. Is that right? Then you need adjust the position of
the dragged object with the amount that the window scrolls. So instead of
looking at the mouse at this point, look at the distance that the window
travels.
HTH
Ivo http://4umi.com/web/javascript/
here is my beautiful example
<html><head>
<style type="text/css">
..drag{
position:relati ve;
cursor:move;
z-index: 100;
}
</style>
<script type="text/javascript">
var dragobject={
z: 0, x: 0, y: 0, offsetx : null, offsety : null, targetobj : null,
dragapproved : 0,
initialize:func tion(){
document.onmous edown=this.drag
document.onmous eup=function(){ this.dragapprov ed=0}
},
drag:function(e ){
var evtobj=window.e vent? window.event : e
this.targetobj= window.event? event.srcElemen t : e.target
if (this.targetobj .className=="dr ag"){
this.dragapprov ed=1
if
(isNaN(parseInt (this.targetobj .style.left))){ this.targetobj. style.left=0}
if
(isNaN(parseInt (this.targetobj .style.top))){t his.targetobj.s tyle.top=0}
this.offsetx=pa rseInt(this.tar getobj.style.le ft)
this.offsety=pa rseInt(this.tar getobj.style.to p)
this.x=evtobj.c lientX
this.y=evtobj.c lientY
if (evtobj.prevent Default)
evtobj.preventD efault()
document.onmous emove=dragobjec t.moveit
}
},
moveit:function (e){
var evtobj=window.e vent? window.event : e
if (this.dragappro ved==1){
this.targetobj. style.left=this .offsetx+evtobj .clientX-this.x+"px"
this.targetobj. style.top=this. offsety+evtobj. clientY-this.y+"px"
return false
}
}
}
dragobject.init ialize()
function getPosition(ev) {
ev = ev || window.event;
var mousepos = getMouseCoords( ev)
if(mousepos.y < posTop()+50){
pageScrollUp(mo usepos.y,ev)
}
}
function getMouseCoords( ev){
if(ev.pageX || ev.pageY){
return{x:ev.pag eX, y:ev.pageY};
}
return {
x:ev.clientX + document.body.s crollLeft - document.body.c lientLeft,
y:ev.clientY + document.body.s crollTop - document.body.c lientTop
};
}
function posTop(){
return typeof window.pageYOff set != 'undefined' ? windowPageYOffs et :
document.docume ntElement
&& document.docume ntElement.scrol lTop ?
document.docume ntElement.scrol lTop : document.body.s crollTop ?
document.body.s crollTop : 0;
}
function pageScrollUp(mo usePosY,ev){
window.scrollBy (0,-80);
var d = document.getEle mentById('myDiv ');
ev = ev || window.event;
var mousepos = getMouseCoords( ev);
d.style.top = (mousePosY - 80)+'px';
}
</script>
</head><body>
<h1>Test test</h1><h1>Test test test</h1><h1>Test test test
test</h1><h1>Test test test test test</h1>
<h1>Test test test test test test</h1><h1>Test test test test
test</h1><h1>Test test test test</h1>
<h1>Test test test</h1><h1>Test test</h1><h1>Test test</h1><h1>Test
test test</h1><h1>Test test test test</h1>
<h1>Test test test test test</h1>
<div id="myDiv" class="drag" style="border:b lue solid
1px;background-color:lightyell ow;width:100px; "
onMouseMove='ge tPosition();'>D rag Me<br>Anywhere</div>
<h1>Test test</h1><h1>Test test test</h1><h1>Test test test
test</h1><h1>Test test test test test</h1>
<h1>Test test test test test test</h1><h1>Test test test test
test</h1><h1>Test test test test</h1>
<h1>Test test test</h1><h1>Test test</h1><h1>Test test</h1><h1>Test
test test</h1><h1>Test test test test</h1>
<h1>Test test test test test</h1>
</body></html> This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Adam |
last post by:
Hi
I had Ruby 1.6.8-8 for Windows installed on my WinXP Pro machine prior
to installing Python 2.3. After installing Python 2.3, I tried to
<----- screen output of python interactive command line ----->
Python 2.3 (#46, Jul 29 2003, 18:54:32) on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> from Tkinter import *
>>> root = Tk()
|
by: your name here |
last post by:
I've been trying to get the scrollby javascript feature to scroll
through frames. My end goal is to make my own scroll buttons to use
for navigation through the frame but I figured I would start simple.
I would load a frameset and just move the correct frame by 100 pixels
right and 100 pixels down. Here is the code I am using:
<html>
<script TYPE="text/javascript">
function scrollme()
|
by: JF |
last post by:
Hi,
I need to change the location of the parent window and after
that scroll a little bit (because of "position:fixed" css buttons,
which obscure the title).
I have
window.opener.location.href = "newhreflabel";
window.opener.scrollBy(0, -25);
|
by: BGC |
last post by:
I'm attempting something like this:
win1 =
window.open("pop_up.html","_blank","width=325,height=272,top=0,left=0,scrollbars=0,resizable=0");
win1.window.scrollBy(100,50);
I've done this before when instead of "_blank" I had a unique name there for
each popup I wanted to open.
ex.
win1= window.open("popup.html","ww1", ........
|
by: Robert Gamble |
last post by:
9899:1999 5.1.2.3 Example 4 reads:
"EXAMPLE 4 Implementations employing wide registers have to take care
to honor appropriate semantics. Values are independent of whether they
are represented in a register or in memory. For example, an implicit
spilling of a register is not permitted to alter the value. Also, an
explicit store and load is required to round to the precision of the
storage type. In particular, casts and assignments are...
| |
by: Michi |
last post by:
Hallo.
I just try to implement a scrolling effect to a drag and drop script.
If you try to drag something to an area beneath the visible area of
your browser window, the window should scroll automatically downwards.
Therefor i defined an area (i.e x-pos = 0px - 200px, y-pos = 500px -
600px), where the page should scroll, if you move the cursor in (while
drag and drop (onmousemove)).
While mousemove i check the coordinates and if they...
|
by: vunet.us |
last post by:
Hello JavaScript experts,
I have a floating div which I drag all over the page. If the page has
scrollbars and users drag the floating div to the very top, page
scrolls up too. The problem occurs at this moment. As page scrolls up,
the div gets detached from the mouse while dragging.
How can I keep the floating div to always stay attached to the mouse
during a dragging process and scrolling the page?
Plug and Play code is a good example...
|
by: lotus18 |
last post by:
Hello World
I have a problem in detecting the conflict schedule (Day and Time).
Day
1. M
2. T
3. W
4. TH
5. F
|
by: lotus18 |
last post by:
Hello all
I have these records on my Day Table for my complete database table please click here
1. M
2. T
3. W
4. TH
5. F
6. S
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |