Dogadjaji u JavaScript-u

Uvod

Događaji su pojave, koje su najčešće rezultat nečega što korisnik uradi (klik mišem, klik na tastaturi, drag and drop….), mada mogu biti izazvane i od strane sistema, browsera… Registrovanje dogadjaja na nekom HTML elementu podrazumeva vezivanje osluškivača dogadjaja (eng. event listener) za HTML elemenat i definisanje posledice tog događaja. Event listener nakon izvršenog dogadjaja poziva na akciju obrađivače događaja (eng. event handler). Event handler je callback funkcija koja se aktivira kao posledica nekog dogadjaja.

Continue reading…


Pregled svojstava event objekta

Uvod

Kada god se desi neki dogadjaj (eng. event), javascript smešta sve relevantne podatke vezane za dogadjaj u “event objekat”, npr. gde je bio mouse pointer, kojim dugmetom je kliknuto, koji element je kliknut… Ovaj objekat se uvek prosledjuje callback funkciji, pa stoga callback funkcija ima pristup svim podacima smeštenim u njemu. Podacima pristupamo preko svojstva event objekta. U ovom članku su okupljena sva svojstva Event objekta.

Glavna svojstva event objekta

Svojstvo objekta Svojstvo objekta Opis DOM
bubbles Returns whether or not a specific event is a bubbling event 2
cancelable Returns whether or not an event can have its default action prevented 2
currentTarget Returns the element whose event listeners triggered the event 2
defaultPrevented Returns whether or not the preventDefault() method was called for the event 3
eventPhase Returns which phase of the event flow is currently being evaluated 2
isTrusted Returns whether or not an event is trusted 3
target Returns the element that triggered the event 2
timeStamp Returns the time (in milliseconds relative to the epoch) at which the event was created 2
type Returns the name of the event 2
view Returns a reference to the Window object where the event occured 2

Svojstva vezana za rad sa mišem

Svojstvo objekta Opis DOM
altKey Returns whether the “ALT” key was pressed when the mouse event was triggered 2
button Returns which mouse button was pressed when the mouse event was triggered 2
buttons Returns which mouse buttons were pressed when the mouse event was triggered 3
clientX Returns the horizontal coordinate of the mouse pointer, relative to the current window, when the
mouse event was triggered
2
clientY Returns the vertical coordinate of the mouse pointer, relative to the current window, when the
mouse event was triggered
2
ctrlKey Returns whether the “CTRL” key was pressed when the mouse event was triggered 2
detail Returns a number that indicates how many times the mouse was clicked 2
metaKey Returns whether the “META” key was pressed when an event was triggered 2
relatedTarget Returns the element related to the element that triggered the mouse event 2
screenX Returns the horizontal coordinate of the mouse pointer, relative to the screen, when an event was
triggered
2
screenY Returns the vertical coordinate of the mouse pointer, relative to the screen, when an event was
triggered
2
shiftKey Returns whether the “SHIFT” key was pressed when an event was triggered 2
which Returns which mouse button was pressed when the mouse event was triggered 2

Svojstva vezana za rad sa tastaturom

Svojstvo objekta Opis DOM
altKey Returns whether the “ALT” key was pressed when the key event was triggered 2
ctrlKey Returns whether the “CTRL” key was pressed when the key event was triggered 2
charCode Returns the Unicode character code of the key that triggered the onkeypress event 2
key Returns the key value of the key represented by the event 3
keyCode Returns the Unicode character code of the key that triggered the onkeypress event, or the Unicode
key code of the key that triggered the onkeydown or onkeyup event
2
location Returns the location of a key on the keyboard or device 3
metaKey Returns whether the “meta” key was pressed when the key event was triggered 2
shiftKey Returns whether the “SHIFT” key was pressed when the key event was triggered 2
which Returns the Unicode character code of the key that triggered the onkeypress event, or the Unicode
key code of the key that triggered the onkeydown or onkeyup event
2

Svojstvo vezano za promenu fokusa

Svojstvo Evernt objekta Opis svojstva DOM
relatedTarget Returns the element related to the element that triggered the event 3

Svojstva vezana za animaciju

Svojstvo Evernt objekta Opis svojstva DOM
animationName Returns the name of the animation
elapsedTime Returns the number of seconds an animation has been running

Svojstva vezana za tranziciju

Svojstvo Evernt objekta Opis svojstva DOM
propertyName Returns the name of the CSS property associated with the transition
elapsedTime Returns the number of seconds a transition has been running

Svojstva vezana za scroll

Svojstvo Evernt objekta Opis svojstva DOM
deltaX Returns the horizontal scroll amount of a mouse wheel (x-axis) 3
deltaY Returns the vertical scroll amount of a mouse wheel (y-axis) 3
deltaZ Returns the scroll amount of a mouse wheel for the z-axis 3
deltaMode Returns a number that represents the unit of measurements for delta values (pixels, lines or pages) 3

Svojstvo vezano za keširanje

Svojstvo Evernt objekta Opis svojstva DOM
persisted Returns whether the webpage was cached by the browser  

Svojstvo vezano za hash poziciju na strani

Svojstvo Evernt objekta Opis svojstva DOM
newURL Returns the URL of the document, after the hash has been changed
oldURL Returns the URL of the document, before the hash was changed