Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I will comment the code inline:</p> <pre><code>//all variables ext,spot,box are defined, not "false" and not 0 and not null if (ext &amp;&amp; spot &amp;&amp; box) { /* We assign onmousemove event handler to the function, in javascript functions are vars * function declared like `function function_name(param) {}` go to global scope, * and almost equal to 'function_name=function(param ) {}' * var local scope use `var function_name=function(param) {}` */ document.getElementById('text-shadow-box').onmousemove = onMouseMove; /* add here is another example, you attach ontouchmove anonymous function, * anonymous function BEGIN NEXT LINE */ document.getElementById('text-shadow-box').ontouchmove = function (e) { // e here it is event object, which passed to handler function as argument //it is jquery call, mean do not start other event handlers after this line e.preventDefault(); e.stopPropagation(); /* call function inMousemove, declared somewhere else The "{ clientX: e.touches[0].clientX, clientY: e.touches[0].clientY }" here is object having two properties - clientX and clientY */ onMouseMove({ clientX: e.touches[0].clientX, clientY: e.touches[0].clientY }); /* anonymous function END NEXT LINE */ }; </code></pre> <p><hr> ontouchmove and other touchscreen events documnted <a href="https://dvcs.w3.org/hg/webevents/raw-file/tip/touchevents.html" rel="nofollow">here</a> it looks that <strong><em>touches</em></strong> is object which handles touches to screen, as i have no touchscreen device i can't check, but it looks like touched elements can be accessed two ways, 1st - using <code>e.touches.item(n)</code> (as described in doc) and second - when using e.touches as array <code>e.touches[n]</code>. The n==0 means 1st touched element as i understand from w3c specs. <hr> event.stopPropagation() </p> <blockquote> <p>Description: Prevents the event from bubbling up the DOM tree, preventing any parent handlers from being notified of the event.</p> </blockquote> <p>event.preventDefault()</p> <blockquote> <p>Description: If this method is called, the default action of the event will not be triggered.</p> </blockquote> <p>So <code>event.stopPropagation()</code> prevent of any parents of that element to receive that event (say you have two folded divs and both have event listener)</p> <p>While <code>event.preventDefault()</code> prevents default action (say you have <code>&lt;a href="test.html"&gt;&lt;/a&gt;</code> and have onclick event handler, so it is good to prevent action which will make browser to load test.html</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload