Set trigger on element outside the animated element Interaction

@RobM @abirana

Example without Interactions that I Made you have to click the green clock icon in the header!
testsite:
https://www.yourweblab.nl/sjef/index.html

Hi both,

Try to animate a opening hours panel that has to slide in from right lo left on click of a button (outside the animated element) and slide back by clicking a icon on the animated element.

How do I set the triggers? Because all I see now is the possibility to trigger the animated element on click and when I go to Custom event I can put in a other element, but I don’t see the trigger.

How do I achieve this with Interactions?

Regards & Thanks,

David

Hi David,
@AllMediaLab
Not positive I fully get your question - nice animation by the way!
So with Interactions you would set your entrance animation with the clock as a trigger and the floating schedule as a target. You can just select the opening hours by clicking on the target and selecting it on the page, or edit the selector. This last one is easiest using an id I found, so something like $#uniqueId. You can then select a premade animation like “slideInRight”.

If there was not a second trigger then you could alternate the animation. Instead, I think the easiest way to be able to have two triggers is to add a second animation and a class indicator. So open the Edit Animation panel and add another transition with a type of “set” then for the property select class → add class. Select whatever you want for the class name - I’ll use “hoursopen”. Then in the advanced options for trigger condition select “doesn’t have class” and add the class name as a value.

Now make a second interaction on the button click. Use the same target. Add your animation, for example “slideOutRight”. Then under advanced options select the trigger condition “has class” and add in the class name you picked. Then open the Edit Animation panel and add the remove class property.

Finally, add an Interaction to the close element. Trigger on click of the element, but target the whole schedule block - again I would use an id, but you can click on the target to select it on the page. For animation select the same animation you used on the button from the named animations list.

That should be it. Let me know if it works/is what you were having the problem with,
Bob

@AllMediaLab checking your example I think your issue is solved if not do let us know.

Hi @RobM & @abirana,

https://www.yourweblab.nl/hours

No the problem is not solved, my demo was not with Interactions, I made a simple setup with Interactions and concentrate first on the first trigger to open the panel from right to left.

Problems:

  • Hide at Start doesn’t function so the panel is visible instead of not visible. (only works on click now)
  • When clicking on Click button Starter Template for Bootstrap#menu-toggle appears in the
    browser, I rather have that not visible.
  • I notice a horizontal scroll bar when the animation plays!

Thanks!

David

Ok on this example I can see the issue but the first link you shared Sjef Diederen Margaten has the same implementation without any issue. That is also your work isn’t it?

Yes but no Interactions is used there! It was just to show what I want to achieve with Interactions.

Oh ok then let me check again.

HI @AllMediaLab,
Did you try my suggestions above? It doesn’t look like your Interactions match up. Also, instead of an anchor link, use a button as the trigger. That way you won’t get the change in the menu bar.
Cheers,
Bob

@RobM here has already given you detailed step but your project got us confusing because you might have removed the script that you shouldn’t.

First off, you’ve set Hide At Start on the link not on the sliding block (#hours-open-wrap) but the main issue is that you’ve removed the script from the head section of the HTML. I’m talking about the scripts that PGIA places which make the PGIA work properly.

So in short you should apply Hide At Start to your sliding element not on the Link

And on the link trigger interaction, go to Advance Options and enable Prevent default action, so that #menu-toggle won’t appear on the browser address bar

And horizontal scroll is appearing because your element is going out of the view of browser. Applying position fixed would be best option here but if you don’t want that then you should apply overflow: hidden to the parent of that slider block.

Thanks for pointing that out it was there before and I did not remove it!

3 Likes

@abirana
Can you please explain what trigger and target i need to set for that?

Did you mean only about Hide At Start? You are targeting #hours-open-wrap so you should apply to this.

By the way, for your removed script it should be best to start with a new project from PG. And copy those HTML elements inside the body.

@abirana
Yes I will do that, but can I just set Hide At Start on a element without Interaction? I wanted to add a Interaction with auto opacity to #hours-open-wrap but without a trigger that doesn’t work. That’s why I ask How do I hide #hours-open-wrap what is the trigger because I can not click that same element.

For an interaction there are two things, one trigger and another target. In your case trigger is the link where you click and target where the animation happens.

So you apply interaction on the trigger, you’ve build your interaction to reveal the target (sliding block). But now you need it to be hidden when the page loads.

So if you want to hide an element, what would you do? Apply some CSS to hide the element or apply Hide At Start, so wherever you apply these properties that element will hide. So in your case you’ll have to hide your sliding element, so that you can reveal it with interaction.

By the way, have you tried and tested my suggestions?

@abirana

Yes it’s working now, only I can’t get rid of the horizontal scroll bar. Only when I apply overflow-x: hidden; to the body it is gone.

Only Hide At Start doesn’t work proper, you see a glimp of the element in the beginning of the animation. Close panel also works now!

I checked your live link, if that is update with what you’ve done then I still see that PGIA script is not there.

Did you fixed this issue?

This is what I advised you to do.

Yes I have to start from scratch, because the code automatically disappears after save in Pinegrow when I paste the code in.

A have put it manually in with Sublime Text now.

While pasting I asked you to only copy the elements inside the body. And after you do that please check if it is there. If it is not there then something should be missing on what you did.

Anyway let if be, why don’t you just copy paste the below code on your existing page. Place is at end of the head.

<script>/* Pinegrow Interactions, do not remove */ (function(){try{if(!document.documentElement.hasAttribute('data-pg-ia-disabled')) { window.pgia_small_mq=typeof pgia_small_mq=='string'?pgia_small_mq:'(max-width:767px)';window.pgia_large_mq=typeof pgia_large_mq=='string'?pgia_large_mq:'(min-width:768px)';var style = document.createElement('style');var pgcss='html:not(.pg-ia-no-preview) [data-pg-ia-hide=""] {opacity:0;visibility:hidden;}html:not(.pg-ia-no-preview) [data-pg-ia-show=""] {opacity:1;visibility:visible;display:block;}';if(document.documentElement.hasAttribute('data-pg-id') && document.documentElement.hasAttribute('data-pg-mobile')) {pgia_small_mq='(min-width:0)';pgia_large_mq='(min-width:99999px)'} pgcss+='@media ' + pgia_small_mq + '{ html:not(.pg-ia-no-preview) [data-pg-ia-hide="mobile"] {opacity:0;visibility:hidden;}html:not(.pg-ia-no-preview) [data-pg-ia-show="mobile"] {opacity:1;visibility:visible;display:block;}}';pgcss+='@media ' + pgia_large_mq + '{html:not(.pg-ia-no-preview) [data-pg-ia-hide="desktop"] {opacity:0;visibility:hidden;}html:not(.pg-ia-no-preview) [data-pg-ia-show="desktop"] {opacity:1;visibility:visible;display:block;}}';style.innerHTML=pgcss;document.querySelector('head').appendChild(style);}}catch(e){console&&console.log(e);}})()</script>

Yes like I said I have done! Thank you!

About the missing code, when I work with Sublime Text I have these issues sometimes.