Nice! Thanks for sharing!

On Thu, Mar 24, 2022 at 10:56 PM Christopher Dodunski (Tapestry) <
chrisfromtapes...@christopher.net.nz> wrote:

> Hi Ben and Thiago,
>
> Thank you for your well considered suggestions on accommodating anchor
> points in returned pages.  I've stored them away for possible future
> use.  I wound up solving the original problem in a rather different way,
> using a RequireJS module.
>
> Background: My web application has a main dashboard page incorporating
> 10 expandable panels, and my original intention was simply in having
> users' browsers return to the correct place on the dashboard after
> temporarily exiting (usually to complete some CRUD action).  The
> particular panel they would've last been using would be in an 'expanded'
> (as opposed to 'collapsed') state, and so I implemented some JS to
> simply scroll the browser to this expanded panel on returning to the
> dashboard - should've thought of this to begin with!
>
> I've included the relevant code snippets below, as this may be of use to
> others looking to do similar. :-)
>
> Kind regards,
>
> Chris Dodunski.
>
>
> ** Dashboard.java **
>
>      @Environmental
>      private JavaScriptSupport javaScriptSupport;
>
>      /**
>       * Scroll to currently expanded panel/zone
>       */
>      public void afterRender(){
>
> javaScriptSupport.require("scroll-to-anchor").with(expandedPanel);
>      }
>
>
> ** scroll-to-anchor.js **
>
> define(["jquery"], function($) {
>
>      return function(aid){
>          var aTag = $("div[id='"+ aid +"']");
>          $('html,body').animate({scrollTop: aTag.offset().top},'slow');
>      }
>
> })
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
> For additional commands, e-mail: users-h...@tapestry.apache.org
>
>

-- 
Thiago

Reply via email to