Jump to content

Panel.HTMLFrame.body.setScrollTo - Top / Left / Right / Bottom


andyhill

Recommended Posts

In my project I can set panel setScrollTop and setScrollLeft with the following code - works as expected.

RightPanel.JSInterface.JSCall('body.setScrollTop', [0]);

TopPanel.JSInterface.JSCall('body.setScrollLeft', [0]);

If I understand correctly, to scroll to bottom I will need a 'div' id in the body script as a locator ? As for right ?

Please advise with code example how to setScrollBottom and setScrollRight an a panel containing a HTMLFrame ? 

Thanks in advance

Link to comment
Share on other sites

Experimenting:-

HTMLFrame ... <head>
                            <script type="text/javascript">  
                               function gotoBottom(id)  
                               {  
                                 var element = document.getElementById(id);  
                                 element.scrollTop = element.scrollHeight - element.clientHeight;  
                               }  
                            </script> 
                         </head>
                         <body id="Right"> ... </body>

...

HTMLFrame.JSInterface.JSCode('gotoBottom("Right");'); // ERRORS Cannot read properties of null (reading 'scrollHeight')

Please advise howto - thanks in advance

Link to comment
Share on other sites

On 9/24/2021 at 2:34 AM, andyhill said:

Experimenting:-

HTMLFrame ... <head>
                            <script type="text/javascript">  
                               function gotoBottom(id)  
                               {  
                                 var element = document.getElementById(id);  
                                 element.scrollTop = element.scrollHeight - element.clientHeight;  
                               }  
                            </script> 
                         </head>
                         <body id="Right"> ... </body>

...

HTMLFrame.JSInterface.JSCode('gotoBottom("Right");'); // ERRORS Cannot read properties of null (reading 'scrollHeight')

 

4 hours ago, andyhill said:

Can you please advise - thanks

Hello,

Please try to create a working example. This does not mean that the problem will be solved, although it will make it easier to reproduce and see the problem.

Link to comment
Share on other sites

4 hours ago, andyhill said:

Any progress

  UniHTMLFrame1.ClientEvents.UniEvents.Clear;
  s:= 'beforeInit=function beforeInit(sender, config)'#13#10+
      '{ '#13#10+
      '  config.minHeight = 3600;'#13#10+ // THIS IS A MUST FOR MY PRODUCTION PROJECT
      '} ';
  UniHTMLFrame1.ClientEvents.UniEvents.Add(s);

This is the reason why scrolling does not work. You need to use UniHTMLFrame.AutoScroll=True instead.

Link to comment
Share on other sites

Yes my test case was thrown together.

Actually in my real project the LeftHTMLFrame and the RightHTMLFrame have NO HEIGHT DECLARATIONS only width (they auto grow based on contents).

          LeftHTMLFrame.ClientEvents.UniEvents.Clear;
          s:= 'beforeInit=function beforeInit(sender, config)'#13#10+
              '{ '#13#10+
              '  config.minWidth = 149;'#13#10+ // 160
              '  config.Width = 149;'#13#10+
              '  config.maxWidth = 149;'#13#10+
              '} ';
          LeftHTMLFrame.ClientEvents.UniEvents.Add(s);
 

          RightHTMLFrame.ClientEvents.UniEvents.Clear;
          s:= 'beforeInit=function beforeInit(sender, config)'#13#10+
              '{ '#13#10+
              '  config.minWidth = 149;'#13#10+ // 160
              '  config.Width = 149;'#13#10+
              '  config.maxWidth = 149;'#13#10+
              '} ';
          RightHTMLFrame.ClientEvents.UniEvents.Add(s);
 

In code I want to scroll to the BOTTOM of the HTMLFrame canvas (horz scrollbar auto shows when canvas contents is longer than the visible parent panel).

Using similar code RightHTMLFrame.JSInterface.JSCall('body.setScrollTop', [0]); ---> (body.setScrollBottom' ...

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...