SlideShare a Scribd company logo
Dive Into Javascript Event




      chengjing@taobao.com
Dive Into Javascript Event




      chengjing@taobao.com
【第一季第二期】Dive into javascript event
Outline

Survey
Scenario
Preparation
Event Type
Event Mechanism
Implement an Event Library
【第一季第二期】Dive into javascript event
Survey
Survey
YAHOO.util.Event.addListener(1,2,3,4,5)
Survey
YAHOO.util.Event.addListener(1,2,3,4,5)

YAHOO.util.Event.on
【第一季第二期】Dive into javascript event
Scenario
Scenario



?
【第一季第二期】Dive into javascript event
Preparation
Preparation


  YUI
Preparation
【第一季第二期】Dive into javascript event
Event Type
Event Type
Interface Events   scroll resize focus blur ...
Event Type
Interface Events   scroll resize focus blur ...
Mouse Events       mouseover mouseout ...
Event Type
Interface Events   scroll resize focus blur ...
Mouse Events       mouseover mouseout ...
Form Events        submit reset ...
Event Type
Interface Events   scroll resize focus blur ...
Mouse Events       mouseover mouseout ...
Form Events        submit reset ...
W3C Events         dom manipulation...
Event Type
Interface Events   scroll resize focus blur ...
Mouse Events       mouseover mouseout ...
Form Events        submit reset ...
W3C Events         dom manipulation...
Microsoft Events   mouseenter mouseleave...
【第一季第二期】Dive into javascript event
Mouse Event
Mouse Event
      dblclick              click

mousedown mousemove mouseover mouseout
Mouse Event
      dblclick              click

mousedown mousemove mouseover mouseout




         mouseenter mouseleave
【第一季第二期】Dive into javascript event
Mouse Event
Mouse Event
【第一季第二期】Dive into javascript event
Event Mechanism
Event Mechanism
Event Mechanism

   Click
Event Mechanism
Event Mechanism
Event Mechanism
Event Mechanism
Event Mechanism
Event Mechanism
Event Mechanism
Event Mechanism
Event Mechanism
Event Registration
Event Mechanism
Event Registration
Event Mechanism
Event Registration
Event Mechanism
Event Registration
Event Mechanism
Event Registration
Event Mechanism
Event Registration
Event Mechanism
Event Registration
Event Mechanism
Event Mechanism
Event Registration
Event Mechanism
Event Registration
Event Mechanism
Event Mechanism
Attention!
Event Mechanism
Attention!
Event Mechanism
Attention!




Same Parameters?
Event Mechanism
Attention!




Same Parameters?
Event Mechanism
Attention!




Same Parameters?
Event Mechanism
Event Mechanism
Same Parameters?
Event Mechanism
Same Parameters?
Event Mechanism
Same Parameters?
Event Mechanism
Same Parameters?

                   ≠
Event Mechanism
Same Parameters?

                   ≠
Event Mechanism
Same Parameters?

                   ≠
Event Mechanism
Same Parameters?

                   ≠

                   ≠
Event Mechanism
Event Mechanism
Sequence of Multiple Listeners
Event Mechanism
Sequence of Multiple Listeners
Event Mechanism
Sequence of Multiple Listeners
Event Mechanism
Sequence of Multiple Listeners




  alert(1)


  alert(2)
Event Mechanism
Sequence of Multiple Listeners




  alert(1)

             Queue
  alert(2)
Event Mechanism
Sequence of Multiple Listeners




  alert(1)

             Queue
  alert(2)
Event Mechanism
Sequence of Multiple Listeners




                                 alert(2)
  alert(1)

             Queue               alert(1)
  alert(2)
Event Mechanism
Sequence of Multiple Listeners




                                 alert(2)
  alert(1)

             Queue      Stack    alert(1)
  alert(2)
Event Mechanism
Event Mechanism
Event Object
Event Mechanism
Event Object
Event Mechanism
Event Mechanism
Turn Bubbling Off
Event Mechanism
Turn Bubbling Off
Event Mechanism
Event Mechanism
Event Target
Event Mechanism
Event Target
Event Mechanism
Event Target
Event Mechanism
Event Target
Event Mechanism
Event Target




               Target will
               always be
               element2
Event Mechanism
Event Target




                  Target will
                  always be
                  element2


e.currentTarget
Event Mechanism
Event Target




                  Target will
                  always be
                  element2


e.currentTarget
Event Mechanism
Event Target




                  Target will
                  always be
                  element2


e.currentTarget
Event Mechanism
Event Mechanism
“This” in Event
Event Mechanism
   “This” in Event
In Javascript this always refers to the “owner” of
the function we’re executing, or rather, to the
object that a function is a method of
Event Mechanism
   “This” in Event
In Javascript this always refers to the “owner” of
the function we’re executing, or rather, to the
object that a function is a method of
   Example: Register click handler on div1
Event Mechanism
   “This” in Event
In Javascript this always refers to the “owner” of
the function we’re executing, or rather, to the
object that a function is a method of
   Example: Register click handler on div1
Event Mechanism
   “This” in Event
In Javascript this always refers to the “owner” of
the function we’re executing, or rather, to the
object that a function is a method of
   Example: Register click handler on div1
Event Mechanism
   “This” in Event
In Javascript this always refers to the “owner” of
the function we’re executing, or rather, to the
object that a function is a method of
   Example: Register click handler on div1
Event Mechanism
   “This” in Event
In Javascript this always refers to the “owner” of
the function we’re executing, or rather, to the
object that a function is a method of
   Example: Register click handler on div1
Event Mechanism
   “This” in Event
In Javascript this always refers to the “owner” of
the function we’re executing, or rather, to the
object that a function is a method of
   Example: Register click handler on div1
Event Mechanism
   “This” in Event
In Javascript this always refers to the “owner” of
the function we’re executing, or rather, to the
object that a function is a method of
   Example: Register click handler on div1
Event Mechanism
   “This” in Event
In Javascript this always refers to the “owner” of
the function we’re executing, or rather, to the
object that a function is a method of
   Example: Register click handler on div1
Event Mechanism
   “This” in Event
In Javascript this always refers to the “owner” of
the function we’re executing, or rather, to the
object that a function is a method of
   Example: Register click handler on div1
Event Mechanism
   “This” in Event
In Javascript this always refers to the “owner” of
the function we’re executing, or rather, to the
object that a function is a method of
   Example: Register click handler on div1
Event Mechanism
   “This” in Event
In Javascript this always refers to the “owner” of
the function we’re executing, or rather, to the
object that a function is a method of
   Example: Register click handler on div1
Event Mechanism
   “This” in Event
In Javascript this always refers to the “owner” of
the function we’re executing, or rather, to the
object that a function is a method of
   Example: Register click handler on div1
Event Mechanism
   “This” in Event
In Javascript this always refers to the “owner” of
the function we’re executing, or rather, to the
object that a function is a method of
   Example: Register click handler on div1
Event Mechanism
   “This” in Event
In Javascript this always refers to the “owner” of
the function we’re executing, or rather, to the
object that a function is a method of
   Example: Register click handler on div1
Event Mechanism
   “This” in Event
In Javascript this always refers to the “owner” of
the function we’re executing, or rather, to the
object that a function is a method of
   Example: Register click handler on div1
Implement an Event Library
Implement an Event Library
Version one: “this”
Implement an Event Library
Version one: “this”
Implement an Event Library
Implement an Event Library
Version Two: e and data
Implement an Event Library
Version Two: e and data
Implement an Event Library
Version Two: e and data
Implement an Event Library
Implement an Event Library
Version Three: Combine e and data
Implement an Event Library
Version Three: Combine e and data
Implement an Event Library
Version Three: Combine e and data
Implement an Event Library
Version Three: Combine e and data
Implement an Event Library
Version Three: Combine e and data

              TODO:
              Encapsulate the original
              event object
Implement an Event Library
Version Three: Combine e and data

              TODO:
              Encapsulate the original
              event object
【第一季第二期】Dive into javascript event
【第一季第二期】Dive into javascript event
Acknowledge
Acknowledge

   PPK: http://www.quirksmode.org

   W3C: http://www.w3.org/TR/2000/REC-DOM-Level-2-

Events-20001113/

   YUI Source Code(v2.8.1): http://developer.yahoo.com/yui/2/

   JQuery Source Code(v1.4): http://jquery.com/

   Google Closure Library: http://code.google.com/closure/

library/
Thanks!

More Related Content

KEY
Dive into javascript event
PPTX
Maintaining Your Code Clint Eastwood Style
PDF
A Series of Fortunate Events - PHP Benelux Conference 2015
PDF
Events: The Object Oriented Hook System.
PDF
Reactive programming with RxJS - Taiwan
PDF
Android intents
PPTX
05 intent
PPTX
Android - Intents - Mazenet Solution
Dive into javascript event
Maintaining Your Code Clint Eastwood Style
A Series of Fortunate Events - PHP Benelux Conference 2015
Events: The Object Oriented Hook System.
Reactive programming with RxJS - Taiwan
Android intents
05 intent
Android - Intents - Mazenet Solution

Viewers also liked (6)

KEY
【第一季第三期】Thinking in Javascript & OO in Javascript - 清羽
PPT
【第一季第一期】开发的前端之痛 by 银环
PPTX
【第一季第四期】JavaScript Optimization
PPTX
【第一季第一期】前端的深化 by 周杰
PPTX
【第一季第五期】要漂亮很容易!——超简单CSS速成教程
PPT
【第一季•第六期】Ajax & JSONP in Action
【第一季第三期】Thinking in Javascript & OO in Javascript - 清羽
【第一季第一期】开发的前端之痛 by 银环
【第一季第四期】JavaScript Optimization
【第一季第一期】前端的深化 by 周杰
【第一季第五期】要漂亮很容易!——超简单CSS速成教程
【第一季•第六期】Ajax & JSONP in Action
Ad

Similar to 【第一季第二期】Dive into javascript event (20)

PPT
jQuery 1.7 Events
PPT
Java gui event
PPTX
ITE 1122_ Event Handling.pptx
PPTX
event-handling.pptx
PDF
JavaScript - Chapter 11 - Events
KEY
openFrameworks 007 - events
PPTX
event-handling.pptx
PPT
Aaai 2011 event processing tutorial
PDF
Event driven application
PPTX
JAVA UNIT 5.pptx jejsjdkkdkdkjjndjfjfkfjfnfn
PPTX
EVENT DRIVEN PROGRAMMING SWING APPLET AWT
PPTX
Advance Java Programming(CM5I) Event handling
PPTX
PROGRAMMING IN JAVA- unit 4-part II
PPT
Vldb 2010 event processing tutorial
PDF
Javascript Browser Events.pdf
PDF
Javascript #8 : événements
PPTX
JavaScript_Events.pptx
PPTX
Lab #2: Introduction to Javascript
PDF
Java Programming :Event Handling(Types of Events)
PPTX
PATTERNS06 - The .NET Event Model
jQuery 1.7 Events
Java gui event
ITE 1122_ Event Handling.pptx
event-handling.pptx
JavaScript - Chapter 11 - Events
openFrameworks 007 - events
event-handling.pptx
Aaai 2011 event processing tutorial
Event driven application
JAVA UNIT 5.pptx jejsjdkkdkdkjjndjfjfkfjfnfn
EVENT DRIVEN PROGRAMMING SWING APPLET AWT
Advance Java Programming(CM5I) Event handling
PROGRAMMING IN JAVA- unit 4-part II
Vldb 2010 event processing tutorial
Javascript Browser Events.pdf
Javascript #8 : événements
JavaScript_Events.pptx
Lab #2: Introduction to Javascript
Java Programming :Event Handling(Types of Events)
PATTERNS06 - The .NET Event Model
Ad

Recently uploaded (20)

PPTX
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
PPT
Teaching material agriculture food technology
PDF
cuic standard and advanced reporting.pdf
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
PPTX
Cloud computing and distributed systems.
PPTX
Spectroscopy.pptx food analysis technology
PPTX
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
PDF
The Rise and Fall of 3GPP – Time for a Sabbatical?
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
PDF
Spectral efficient network and resource selection model in 5G networks
PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
PDF
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
PDF
Approach and Philosophy of On baking technology
PDF
Empathic Computing: Creating Shared Understanding
PDF
Unlocking AI with Model Context Protocol (MCP)
PDF
Machine learning based COVID-19 study performance prediction
PPTX
Understanding_Digital_Forensics_Presentation.pptx
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
Teaching material agriculture food technology
cuic standard and advanced reporting.pdf
Digital-Transformation-Roadmap-for-Companies.pptx
Diabetes mellitus diagnosis method based random forest with bat algorithm
Cloud computing and distributed systems.
Spectroscopy.pptx food analysis technology
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
The Rise and Fall of 3GPP – Time for a Sabbatical?
Reach Out and Touch Someone: Haptics and Empathic Computing
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
Spectral efficient network and resource selection model in 5G networks
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
Approach and Philosophy of On baking technology
Empathic Computing: Creating Shared Understanding
Unlocking AI with Model Context Protocol (MCP)
Machine learning based COVID-19 study performance prediction
Understanding_Digital_Forensics_Presentation.pptx

【第一季第二期】Dive into javascript event