Jump to content

O.T. Javascript fuction - Add ScrollTop to variable


Recommended Posts

Posted

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+'''])'+
                        '};'+
                        '}'+
                    '})'+
                '}'
                );
Posted

Hi Erich,

 

UniScrollBox1 -

 

top ->

MainForm.UniScrollBox1.el.getTop()

scrollable area top ->

Ext.get(MainForm.UniScrollBox1.id+'-innerCt').el.getTop()

Best regards,

Posted

Hi and Thanx ..

 

 

if i move the vertical scrollbar of uniScrollbox1 to the bottom, the value of "getTop" is just the same ...  i search the value, how may pixels i scrolled down (and left) 

Posted

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

Posted

Math.abs(Ext.get(VISUAL.UniScrollBox1.id+'-innerCt').el.getTop()

Math.abs(Ext.get(VISUAL.UniScrollBox1.id+'-innerCt').el.getLeft()

 

try to replace to: "-innerCt", (use double quotes)

Posted

Puhh ... sorry to make such problems with this ...

 

It doesnt work .. if uniscrollbox1 is scrolled - it makes problems ...

 

 

i made a testcase..

 

Please save image.png in "files"-folder 

Project1.zip

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
×
×
  • Create New...