< Return to Video

Events Overview - Google Web Designer

  • 0:04 - 0:09
    Hi. My name is Maciek and I'm an
    engineer on Google Web Designer.
  • 0:09 - 0:12
    Today I'll show you how to use
    Google Web Designer's event system.
  • 0:13 - 0:15
    By the end of this video,
  • 0:15 - 0:18
    you'll know how to set up
    event handlers in your documents.
  • 0:19 - 0:21
    I've prepared a simple document
    for us to use,
  • 0:21 - 0:24
    which contains a carousel gallery
    and a blue div.
  • 0:25 - 0:27
    In order to add event handlers
    to your document,
  • 0:27 - 0:31
    you're going to want to find the
    events panel here on the right side.
  • 0:32 - 0:36
    This will show you a list of all of
    your installed event handlers.
  • 0:36 - 0:38
    We don't have any handlers yet here,
  • 0:38 - 0:40
    so the list is empty.
  • 0:40 - 0:41
    But if you have a lot of them,
  • 0:41 - 0:44
    you can sort and filter through them.
  • 0:45 - 0:47
    To add event handlers to this list,
  • 0:47 - 0:49
    we're going to need to bring up the
    events dialogue.
  • 0:49 - 0:52
    There are a couple of ways
    to get to that dialogue.
  • 0:52 - 0:56
    One way, if you already know
    which target you want to select,
  • 0:56 - 1:00
    you can right-click on an element
    and select 'Add event'.
  • 1:00 - 1:03
    This will set the selected element
    as your target.
  • 1:04 - 1:08
    Instead, let's deselect that element
    and open the events dialogue
  • 1:08 - 1:11
    using this little 'plus'
    icon in the corner.
  • 1:13 - 1:16
    This will open up the events dialogue
    without any preferences selected.
  • 1:17 - 1:20
    The first thing we want to do
    is select the target.
  • 1:20 - 1:23
    This is the element that will
    trigger our event handler.
  • 1:23 - 1:26
    For this example,
    I'm going to choose the carousel.
  • 1:27 - 1:30
    Next, we need to choose an event
    which will trigger our event handler.
  • 1:31 - 1:34
    Most elements support
    'Mouse' and 'Touch' events.
  • 1:34 - 1:38
    Since this is a carousel, it also
    supports some special, specific events.
  • 1:38 - 1:40
    I'm going to select the 'click' event,
  • 1:40 - 1:43
    and now we get to choose an action.
  • 1:43 - 1:47
    This is the action that we want to perform
    in response to the event.
  • 1:48 - 1:52
    Most elements support setting CSS styles,
  • 1:52 - 1:55
    and adding custom actions,
    which we'll get to in a minute.
  • 1:55 - 1:58
    If you have other custom elements
    in your documents,
  • 1:58 - 2:01
    they might have additional events
    here for you to select.
  • 2:02 - 2:05
    For this demo,
    I'm going to choose 'Set styles'.
  • 2:05 - 2:08
    Next, we're going to choose a receiver.
  • 2:08 - 2:11
    This is the element whose CSS
    we want to change.
  • 2:11 - 2:14
    For this demo,
    I'm going to choose the blue div,
  • 2:15 - 2:17
    and I'll assign some CSS properties to it.
  • 2:17 - 2:23
    I'll change the background colour
    of the div to be red.
  • 2:24 - 2:27
    You can choose some easing options,
  • 2:27 - 2:29
    add a duration,
  • 2:29 - 2:31
    and click 'OK' to save.
  • 2:31 - 2:35
    That's it. We've added an
    event handler to our document.
  • 2:35 - 2:37
    Now we can go ahead and
    preview the document,
  • 2:37 - 2:39
    and see what we've made.
  • 2:42 - 2:46
    Now we see when I
    click on the carousel,
  • 2:46 - 2:48
    the blue div slowly changes to red.
  • 2:49 - 2:51
    That was pretty easy.
  • 2:52 - 2:56
    Now, let's say we've made a mistake
    and we want to change our event handler.
  • 2:56 - 2:59
    We don't need to make
    a whole, brand new event handler.
  • 2:59 - 3:02
    We can just edit the one
    that we've currently made.
  • 3:03 - 3:05
    If you double-click on the event handler,
  • 3:05 - 3:09
    it will open up the events dialogue
    in editing mode.
  • 3:09 - 3:14
    Let's go back to the actions screen and
    select 'custom action'.
  • 3:15 - 3:19
    Here, you can write any valid
    JavaScript code.
  • 3:20 - 3:25
    I'm going to go ahead and
    give the code a function name.
  • 3:26 - 3:30
    And for the purpose of this demo,
    let's just make an alert call.
  • 3:38 - 3:39
    That looks good.
  • 3:40 - 3:42
    Now click 'OK' to save.
  • 3:43 - 3:46
    We see that our event handler
    has been updated,
  • 3:47 - 3:50
    to show that we're going to call
    my function.
  • 3:51 - 3:53
    Let's preview it.
  • 3:56 - 3:59
    Now when I click on the carousel,
  • 3:59 - 4:01
    we see the alert statement come up:
  • 4:01 - 4:03
    'I love Google Web Designer!'
  • 4:07 - 4:09
    That's it for today.
  • 4:09 - 4:11
    If you have any questions about events,
  • 4:11 - 4:13
    or any other Google Web Designer topics,
  • 4:13 - 4:15
    just post them in the comments section.
  • 4:15 - 4:16
    Thank you.
Title:
Events Overview - Google Web Designer
Description:

more » « less
Duration:
04:19

English, British subtitles

Revisions