Jump to content

O.T. Javascript fuction - Add ScrollTop to variable


erich.wanker

Recommended Posts

Hi,

 

how can i calculate the correct position of a element placed in a uniScrollBox?

 

 

 

in form VISUAL -> uniscrollbox1, i have a uniImage  - to read the position of uniImage - i must add the scrolled area of uniScrollbox ..

 

i tryed:

'var mein_top = me.el.getTop() + VISUAL.uniScrollBox1.el.scrollX;'+
'var mein_left = me.el.getLeft() + VISUAL.uniScrollBox1.el.scrollY;'+

but works just by the FIRST drag/drop action ..

 

if i dragg a image ONE time .. it works, but after this moment EVERY click on the form makes a new position of the selected image ... 

 

 

the hole code is:

            meine_marker[meine_marker_anzahl].JSInterface.JSAddListener(
                'afterrender',
                'function(me) {'+
                    'Ext.onReady(function() {'+
                        'me.dd=new Ext.dd.DDProxy(me, "");'+
                        'me.constrain=true;'+
                        'me.dd.startDrag=function() {'+
                            'this.constrainX=true;'+
                            'this.maxX=VISUAL.display_image.el.getRight()-me.width;'+
                            'this.minX=VISUAL.form.getX();'+
                            'this.constrainY=true;'+
                            'this.maxY=VISUAL.display_image.el.getBottom()-me.height;'+
                            'this.minY=VISUAL.form.getY();'+
                        'me.dd.afterDrag=function() {'+
                        'var mein_top = me.el.getTop() + VISUAL.uniScrollBox1.el.scrollX;'+
                        'var mein_left = me.el.getLeft() + VISUAL.uniScrollBox1.el.scrollY;'+
                        'ajaxRequest(VISUAL.form,''MARKER'',[''param0= ''+mein_top+'''',''param1= ''+mein_left+'''',''param2='+UniMainModule.VISUAL_MARKER.FieldByName('INR').AsString+'''])'+
                        '};'+
                        '}'+
                    '})'+
                '}'
                );
Link to comment
Share on other sites

if i integrate your code - the webbrowser crashes ....

meine_marker[meine_marker_anzahl].JSInterface.JSAddListener(
                'afterrender',
                'function(me) {'+
                    'Ext.onReady(function() {'+
                        'me.dd=new Ext.dd.DDProxy(me, "");'+
                        'me.constrain=true;'+
                        'me.dd.startDrag=function() {'+
                            'this.constrainX=true;'+
                            'this.maxX=VISUAL.display_image.el.getRight()-me.width;'+
                            'this.minX=VISUAL.form.getX();'+
                            'this.constrainY=true;'+
                            'this.maxY=VISUAL.display_image.el.getBottom()-me.height;'+
                            'this.minY=VISUAL.form.getY();'+
                        'me.dd.afterDrag=function() {'+
                        'var mein_top = me.el.getTop() + Math.abs(Ext.get(VISUAL.UniScrollBox1.id+'-innerCt').el.getTop() - VISUAL.UniScrollBox1.el.getTop());'+
                        'var mein_left = me.el.getLeft() + Math.abs(Ext.get(VISUAL.UniScrollBox1.id+'-innerCt').el.getLeft() - VISUAL.UniScrollBox1.el.getLeft());'+
                        'ajaxRequest(VISUAL.form,''MARKER'',[''param0= ''+mein_top+'''',''param1= ''+mein_left+'''',''param2='+UniMainModule.VISUAL_MARKER.FieldByName('INR').AsString+'''])'+
                        '};'+
                        '}'+
                    '})'+
                '}'
                );

 

to explain what i mean ;-)

 

 

 

 

EXAMPLE

 

uniScollbox width and Heigh is 200px

 

uniscrollbox is scrolled horizontal = 300px   ( a not visible area of 300px on the left side in uniscrollbox1)

 

 

now in the horizontal middle of UniScrollbox is my "marker_image"  

-> real left coordinates of   "marker_image"  = 400px .. ( 300px scrolled left + 100px (Middle of 200px width scrollbox)

 

BUT the JAVASCRIP-function of "var mein_left = me.el.getLeft()"  gives me 100px .. but i need the right value (400px)

 

 

 

any ideas?

 

thanX

Erich

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...