Change object order with javascript?

Is it possible to “Bring an object to front” with javascript or any other dynamic way?

Hi,

You can add the following script to On Load event of the slide to bring an object to the front.

// bring to front
prez.object('object name').node.style.zIndex = 1000;

Regards,

This doesnt seem to work when put in a master slide.
Placeholder content still sits higher in zorder.

eg. I have a hidden box that shows when pressing a button with the z-order javascript setting it to 1000 in the master template. On my main slide i have a text box, this text boxwill sit over the top of the hidden box no matter what i set the z-score too in the master.

Please make sure the your hidden box has an unique name within the master layour and the normal slide that uses the layout. In addition, the changing z-index action must come before the Show Object Blocking action.

Regards

How can i tell if the hidden box has a unique name in the normal side, it doesnt show the objects brought from the master?
I’ve also noticed that hidden slides in the master appear in the normal slide, even if they are both hidden and set as “initially hidden”. Although they correctly dont show on preview.
I will email you my sample to show the z-layer issue now.

Just give it a name instead of using the default name.
I’ve received your project but I don’t see any issue with the z-index.

Regards

It works for the thumbs up green box, but fails for the question mark orange box

I found that you type the incorrect object name in your script so the issue.
I’ve replied to your email with the detail.

Regards

Hi,

I think I got a similar problem.

I got a uniquely named object (Shape_6) in the masterslide. On drag start I set the zIndex to 1300: →
this.node.style.zIndex =1300;

On load in the slide itself I set the zIndex of another uniquely named object to 1000: → prez.object(‘Shape_3’).node.style.zIndex =1000;

when I drag Shape 6 over Shape 3 it will still stay behind Shape 3.

Setting the zIndex for objects within the master works as expected.
Setting the zIndex for objects within the slide works as expected.

However, I do not manage to get the object from the master appear in front of those from the slide.

Could you maybe please send me an example project as well?
That would be much appreciated.

Thanks and best wishes,
Rolf

Hi,

I am afraid that there is no way to get the object from the master to appear in front of objects in the slide, Rolf.
Because the object in the master is placed in different layers under the objects in the slide.

Hope it clarifies.
Regards,
Thuy

1 Like

Thanks, Thuy,

that explains a lot.

My problem in more detail:

Would it, then, maybe, be possible to do the following:

on drag start (from a master slide object), hide all objects on the current slide that start with the same string in their name, e.g. ‘Help_cat’, ‘Help_hero’, ‘Help_tree’.

The point is, I do not know the exact unique names of the objects in the slide. Can I use something like a regular expression in JS to tell AP:
as soon as you start dragging the object in the master slide, hide all the objects in the current slide that start in ‘Help_’?

Thanks a lot and best wishes,
Rolf

I believe that the answer here Sustain user input in master - #8 by ToanLS will address your concern.
Please navigate there for detailed information, Rolf.

All the best,
Thuy

Thank you, Thuy, it does!

Hi, would it be possible to get an example project that shows how this works?
Thanks, Rolf

Please provide us with more specific information about your concern so we can help, @Rolf

I am just a little confused.

It seems like the project of systemnova (Change object order with javascript? - #3 by systemnova) seems to work in the sense that an object from the master slide can actually be put in front of an object from the main slide.

As far as I understood your (Thuy) response (Change object order with javascript? - #10 by PhuongThuy_Le) and also from my own experience, this does not seem to work.

I assume that I misunderstood systemnova’s post and Toan’s answer. Therefore, I was interested to take a look at systemnova’s project.

Hope that helps to clarify,
Thanks,
Rolf

Hi Rolf,

For your information, what systemnova mentioned is the project created in ActivePresenter 8.
In that version, the objects in the slide master lie under the objects in the slide but on the same layer. For that reason, we can use JavaScript to move the position of the objects in the slide master up.

But in ActivePresenter 9, we added some transition effects. Objects in slide master and objects in slide are put in two layers.
So, the objects in the slide master cannot be set up on top.

Best regards,
Thuy

Thanks, Thuy,
that explains a lot.
Best,
Rolf