tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

events.js (1068B)


      1 /* This Source Code Form is subject to the terms of the Mozilla Public
      2 * License, v. 2.0. If a copy of the MPL was not distributed with this
      3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
      4 "use strict";
      5 
      6 /**
      7 * Prevent event default behaviour and stop its propagation.
      8 *
      9 * @param  {object} event
     10 *         Event or react synthetic event.
     11 */
     12 exports.preventDefaultAndStopPropagation = function (event) {
     13  event.preventDefault();
     14  event.stopPropagation();
     15  if (event.nativeEvent) {
     16    if (event.nativeEvent.preventDefault) {
     17      event.nativeEvent.preventDefault();
     18    }
     19    if (event.nativeEvent.stopPropagation) {
     20      event.nativeEvent.stopPropagation();
     21    }
     22  }
     23 };
     24 
     25 /**
     26 * Returns true if the pointer event can perform drag.
     27 *
     28 * We want to handle a drag during a button is pressed.  So, we can ignore
     29 * pointer events which are caused by other devices.
     30 *
     31 * @param {PointerEvent} event
     32 * @returns {boolean}
     33 */
     34 exports.canPointerEventDrag = function (event) {
     35  return event.pointerType == "mouse" || event.pointerType == "pen";
     36 };