Always on top action bar

Game development with Board Game Arena Studio
Post Reply
User avatar
Mistergos
Posts: 79
Joined: 18 September 2011, 16:59

Always on top action bar

Post by Mistergos »

Hi there

I develop a game with a huge board. I added left and right button to scroll left and right using the scrollmap component provided by BGA.
User can scroll normally up and down using mouse or usual slide move (no overriding).

Everything works fine. No problem.

All the user input is hold in a panel on top of the screen (see attachment).
Capture.JPG
Capture.JPG (83.09 KiB) Viewed 908 times
My question is, how can i make it always on top like the main title bar?
Do i have to insert my div directly to main title bar or is there a proper way?
What i would like to do is basically merge the 2 buttons bar (my own and main title).

Thanks for your help
User avatar
Victoria_La
Posts: 665
Joined: 28 December 2015, 20:55

Re: Always on top action bar

Post by Victoria_La »

User avatar
DoctorPelusa
Posts: 36
Joined: 16 March 2020, 12:32

Re: Always on top action bar

Post by DoctorPelusa »

Not sure if that would work for you, but maybe CSS sticky property can do the trick: https://www.w3schools.com/howto/howto_c ... lement.asp
User avatar
Snapper67
Posts: 14
Joined: 27 April 2011, 03:03

Re: Always on top action bar

Post by Snapper67 »

Look at position: fixed, or position:sticky
User avatar
Mistergos
Posts: 79
Joined: 18 September 2011, 16:59

Re: Always on top action bar

Post by Mistergos »

Thanks for all your replies.
Position fixed is indeed the way to go.
I hooked my div on page-title and move as it goes. It works well but assumed that there is #page-title and #after-page-title. So my question is more is there a better way or ican assume these 2 elements will always be there.

For those intersted, here is my code. It is working assuming #page-title and #after-page-title are always there.

In js setup

Code: Select all

            dojo.connect(window, 'onscroll', this, 'fixDiceBar');
            dojo.connect(window, 'onresize', this, 'fixDiceBar');
            this.fixDiceBar(null);
  
later in js

Code: Select all

        
        fixDiceBar : function(event)
        {
            var scrollTop = dojo._docScroll().y;
      	  var el = dojo.query('.fixedElement')[0];
      	  var afterPageTitle = dojo.query('#after-page-title')[0];
    	  el.style.width = dojo.query('#page-title')[0].style.width;
        	  if(afterPageTitle.style.height!="0px" && (el.style.position != 'fixed' || el.style.top == '0px' || el.style.top == '' ))
        		  {
      		  	el.style.position = 'fixed';      		  	
    		  	el.style.top = dojo.query('#after-page-title')[0].style.height;
        		  }
        	  
        	  if((afterPageTitle.style.height=="0px" || afterPageTitle.style.height=='') && el.style.position == 'fixed')
        		  {
      		  		el.style.position = 'static';
        		  	el.style.top = "0px";            		  
        		  }
       };
        
And finally the css

Code: Select all


<div  class="whiteblock fixedElement">
</div>

Post Reply

Return to “Developers”