Jump to content

Canvas z-index in 2.5


max123
 Share

Recommended Posts

Hi All, Happy new Year!

It looks like there's something in v. 2.5 that's causing canvas to change its z-index.

There is a screen with a top bar and a close button that sits on top of the canvas element. When you tap on the canvas on a mobile device (iOS 10), the top bar disappears. This does not happen with v. 2.4.

Unfortunately, I can't provide a PR this time as it's a massive application.
 

Link to comment
Share on other sites

@Deltakosh 

my html ui also disapeared after i upgraded to 2.5 a few days ago, haven't had time to look at it yet, but here's a quick PG, might be the same issue..;

http://www.babylonjs-playground.com/#26VITS#4

a 200x75px orange rectangle should be seen at upper left corner of the canvas.

It only seems to be the case when you add it inside the canvas element itself, 

e.g, if you add it outside canvas element it works; http://www.babylonjs-playground.com/#26VITS#3 but it's of course not placed correctly when the canvas doesn't fit the entire window 

Link to comment
Share on other sites

Hi @Deltakosh, I've found what's causing the problem!

In the the new version of Babylon, you're setting the tabIndex of the Canvas element inside Cameras. This causes the iOS Safari to totally screw up the layout. 
I haven't tested on other mobile browsers. Is there a reason for adding tab index? 

Cheers

Link to comment
Share on other sites

Wouldn't it make more sense to enable tabIndex in Babylon via Camera properties or inside a properties object passed to Cameras' constructor?

Like so:
 

constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, settings:any) {
...
}

/// Settings
{
  setTabIndex: true,
  otherProperty: 3253453245
}

 

Link to comment
Share on other sites

Hi Delta 

Of course it is easier to change tabIndex of UI! :)

But from consistency point of view this looks like a magic trick. How would a newcomer to Babylon know that the reason his beautiful webgl app is not working on iPhone is because there's a tabIndex set somewhere inside BJS's framework that messes up the layout? And it WILL mess up any layout using flexbox. I'd rather leave it to users to deal with CSS/UI, not the framework as results will be unpredictable at best. It took me good 3-4 hours of googling + searching BJS source code to figure out why it stopped working... And what if I started from scratch? - I'd presume it doesn't work, period.

Anyway, it's just my point of view; you're da daddy of Babylon and it's up to you to make these decisions :)

Link to comment
Share on other sites

19 hours ago, Deltakosh said:

I just would love to remove the tabIndex hack but I just CAN'T remenber why we added it. But I'm sure it was already there in 2.4 so this inconsistency certainly comes from iOS (or I missed something:))

No, I'm pretty sure it wasn't there in 2.4.

Link to comment
Share on other sites

19 hours ago, Deltakosh said:

Ok I know why:) Without it I cannot capture the keyboard

I seeeeee... Why don't you use smth like element.focus() instead? That's what I did with 2.4. Anyway, I'd leave this outside the framework and let users handle their UI/events. Otherwise, there will always be unhappy bunnies - some about layout (me), some about unintended focus events :)

Link to comment
Share on other sites

It certainly does! :) 

I used this approach with v.2.4 when building a game. I can PM you a controller file (Typescript) where I init levels; unfortunately, I can't send the whole code base - NDA.

Anyway, here's the game: https://game2016.videotel-cloud.com/
It does run and init properly on touch devices, including iPhone, albeit a tad slow.

Our marketing team will probably write smth about it - I'll make sure they include a sentence about tech (Babylon) and a linkey to your site. :) 

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.
Note: Your post will require moderator approval before it will be visible.

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.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...