Search code examples
amp-html

amp-lightbox: How to close current modal and open other in one action?


I use amp-lightbox component to show detail information: https://ampbyexample.com/components/amp-lightbox/.

amp-lightbox tag has on attribute to open and close modal window:

  • for open: on="tap:my-lightbox"
  • for close: on="tap:my-lightbox.close"

I need to show "Next item", so I need close and open at a moment. How can I do this?


Solution

  • You can use multiple actions at the same time by separating with a comma:

    on="tap:my-lightbox1.close,my-lightbox2.open" 
    

    [EDIT] More about AMP events and actions here: https://github.com/ampproject/amphtml/blob/master/spec/amp-actions-and-events.md