Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

react-dnd-touch-backend

Package Overview
Dependencies
Maintainers
3
Versions
71
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-dnd-touch-backend - npm Package Compare versions

Comparing version 15.0.2 to 15.1.0

dist/esm/index.mjs

18

dist/cjs/index.js

@@ -7,23 +7,23 @@ "use strict";

exports.TouchBackend = void 0;
var _touchBackendImpl = _interopRequireWildcard(require("./TouchBackendImpl"));
Object.keys(_touchBackendImpl).forEach(function(key) {
var _touchBackendImplJs = _interopRequireWildcard(require("./TouchBackendImpl.js"));
Object.keys(_touchBackendImplJs).forEach(function(key) {
if (key === "default" || key === "__esModule") return;
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
if (key in exports && exports[key] === _touchBackendImpl[key]) return;
if (key in exports && exports[key] === _touchBackendImplJs[key]) return;
Object.defineProperty(exports, key, {
enumerable: true,
get: function() {
return _touchBackendImpl[key];
return _touchBackendImplJs[key];
}
});
});
var _interfaces = _interopRequireWildcard(require("./interfaces"));
Object.keys(_interfaces).forEach(function(key) {
var _interfacesJs = _interopRequireWildcard(require("./interfaces.js"));
Object.keys(_interfacesJs).forEach(function(key) {
if (key === "default" || key === "__esModule") return;
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
if (key in exports && exports[key] === _interfaces[key]) return;
if (key in exports && exports[key] === _interfacesJs[key]) return;
Object.defineProperty(exports, key, {
enumerable: true,
get: function() {
return _interfaces[key];
return _interfacesJs[key];
}

@@ -54,3 +54,3 @@ });

const TouchBackend = function createBackend(manager, context = {}, options = {}) {
return new _touchBackendImpl.TouchBackendImpl(manager, context, options);
return new _touchBackendImplJs.TouchBackendImpl(manager, context, options);
};

@@ -57,0 +57,0 @@ exports.TouchBackend = TouchBackend;

@@ -6,10 +6,10 @@ "use strict";

var _invariant = require("@react-dnd/invariant");
var _interfaces = require("./interfaces");
var _predicates = require("./utils/predicates");
var _offsets = require("./utils/offsets");
var _math = require("./utils/math");
var _supportsPassive = require("./utils/supportsPassive");
var _optionsReader = require("./OptionsReader");
var _interfacesJs = require("./interfaces.js");
var _predicatesJs = require("./utils/predicates.js");
var _offsetsJs = require("./utils/offsets.js");
var _mathJs = require("./utils/math.js");
var _supportsPassiveJs = require("./utils/supportsPassive.js");
var _optionsReaderJs = require("./OptionsReader.js");
const eventNames = {
[_interfaces.ListenerType.mouse]: {
[_interfacesJs.ListenerType.mouse]: {
start: 'mousedown',

@@ -20,3 +20,3 @@ move: 'mousemove',

},
[_interfaces.ListenerType.touch]: {
[_interfacesJs.ListenerType.touch]: {
start: 'touchstart',

@@ -26,3 +26,3 @@ move: 'touchmove',

},
[_interfaces.ListenerType.keyboard]: {
[_interfacesJs.ListenerType.keyboard]: {
keydown: 'keydown'

@@ -88,3 +88,3 @@ }

addEventListener(subject, event, handler, capture = false) {
const options = _supportsPassive.supportsPassive ? {
const options = _supportsPassiveJs.supportsPassive ? {
capture,

@@ -101,3 +101,3 @@ passive: false

removeEventListener(subject, event, handler, capture = false) {
const options = _supportsPassive.supportsPassive ? {
const options = _supportsPassiveJs.supportsPassive ? {
capture,

@@ -217,6 +217,6 @@ passive: false

const element = this.sourceNodes.get(sourceId);
return element && (0, _offsets).getNodeClientOffset(element);
return element && (0, _offsetsJs).getNodeClientOffset(element);
};
this.handleTopMoveStartCapture = (e)=>{
if (!(0, _predicates).eventShouldStartDrag(e)) {
if (!(0, _predicatesJs).eventShouldStartDrag(e)) {
return;

@@ -234,3 +234,3 @@ }

this.handleTopMoveStart = (e)=>{
if (!(0, _predicates).eventShouldStartDrag(e)) {
if (!(0, _predicatesJs).eventShouldStartDrag(e)) {
return;

@@ -242,5 +242,5 @@ }

// 3. If there's an anchor link as a child, tap won't be triggered on link
const clientOffset = (0, _offsets).getEventClientOffset(e);
const clientOffset = (0, _offsetsJs).getEventClientOffset(e);
if (clientOffset) {
if ((0, _predicates).isTouchEvent(e)) {
if ((0, _predicatesJs).isTouchEvent(e)) {
this.lastTargetTouchFallback = e.targetTouches[0];

@@ -253,3 +253,3 @@ }

this.handleTopMoveStartDelay = (e)=>{
if (!(0, _predicates).eventShouldStartDrag(e)) {
if (!(0, _predicatesJs).eventShouldStartDrag(e)) {
return;

@@ -278,3 +278,3 @@ }

const enableHoverOutsideTarget = this.options.enableHoverOutsideTarget;
const clientOffset = (0, _offsets).getEventClientOffset(e1, this.lastTargetTouchFallback);
const clientOffset = (0, _offsetsJs).getEventClientOffset(e1, this.lastTargetTouchFallback);
if (!clientOffset) {

@@ -284,3 +284,3 @@ return;

// If the touch move started as a scroll, or is is between the scroll angles
if (this._isScrolling || !this.monitor.isDragging() && (0, _math).inAngleRanges(this._mouseClientOffset.x || 0, this._mouseClientOffset.y || 0, clientOffset.x, clientOffset.y, this.options.scrollAngleRanges)) {
if (this._isScrolling || !this.monitor.isDragging() && (0, _mathJs).inAngleRanges(this._mouseClientOffset.x || 0, this._mouseClientOffset.y || 0, clientOffset.x, clientOffset.y, this.options.scrollAngleRanges)) {
this._isScrolling = true;

@@ -291,3 +291,3 @@ return;

if (!this.monitor.isDragging() && // eslint-disable-next-line no-prototype-builtins
this._mouseClientOffset.hasOwnProperty('x') && moveStartSourceIds && (0, _math).distance(this._mouseClientOffset.x || 0, this._mouseClientOffset.y || 0, clientOffset.x, clientOffset.y) > (this.options.touchSlop ? this.options.touchSlop : 0)) {
this._mouseClientOffset.hasOwnProperty('x') && moveStartSourceIds && (0, _mathJs).distance(this._mouseClientOffset.x || 0, this._mouseClientOffset.y || 0, clientOffset.x, clientOffset.y) > (this.options.touchSlop ? this.options.touchSlop : 0)) {
this.moveStartSourceIds = undefined;

@@ -374,3 +374,3 @@ this.actions.beginDrag(moveStartSourceIds, {

this.lastTargetTouchFallback = undefined;
if (!(0, _predicates).eventShouldEndDrag(e)) {
if (!(0, _predicatesJs).eventShouldEndDrag(e)) {
return;

@@ -395,3 +395,3 @@ }

};
this.options = new _optionsReader.OptionsReader(options, context);
this.options = new _optionsReaderJs.OptionsReader(options, context);
this.actions = manager.getActions();

@@ -407,9 +407,9 @@ this.monitor = manager.getMonitor();

if (this.options.enableMouseEvents) {
this.listenerTypes.push(_interfaces.ListenerType.mouse);
this.listenerTypes.push(_interfacesJs.ListenerType.mouse);
}
if (this.options.enableTouchEvents) {
this.listenerTypes.push(_interfaces.ListenerType.touch);
this.listenerTypes.push(_interfacesJs.ListenerType.touch);
}
if (this.options.enableKeyboardEvents) {
this.listenerTypes.push(_interfaces.ListenerType.keyboard);
this.listenerTypes.push(_interfacesJs.ListenerType.keyboard);
}

@@ -416,0 +416,0 @@ }

@@ -8,3 +8,3 @@ "use strict";

exports.getEventClientOffset = getEventClientOffset;
var _predicates = require("./predicates");
var _predicatesJs = require("./predicates.js");
const ELEMENT_NODE = 1;

@@ -33,3 +33,3 @@ function getNodeClientOffset(node) {

function getEventClientOffset(e, lastTargetTouchFallback) {
if ((0, _predicates).isTouchEvent(e)) {
if ((0, _predicatesJs).isTouchEvent(e)) {
return getEventClientTouchOffset(e, lastTargetTouchFallback);

@@ -36,0 +36,0 @@ } else {

import type { BackendFactory } from 'dnd-core';
export * from './interfaces';
export * from './TouchBackendImpl';
export * from './interfaces.js';
export * from './TouchBackendImpl.js';
export declare const TouchBackend: BackendFactory;

@@ -1,2 +0,2 @@

import type { TouchBackendOptions, AngleRange, TouchBackendContext } from './interfaces';
import type { TouchBackendOptions, AngleRange, TouchBackendContext } from './interfaces.js';
export declare class OptionsReader implements TouchBackendOptions {

@@ -3,0 +3,0 @@ private args;

import type { Backend, Identifier, DragDropManager, Unsubscribe } from 'dnd-core';
import { TouchBackendOptions, TouchBackendContext } from './interfaces';
import { TouchBackendOptions, TouchBackendContext } from './interfaces.js';
export declare class TouchBackendImpl implements Backend {

@@ -4,0 +4,0 @@ private options;

@@ -1,3 +0,3 @@

import type { AngleRange } from '../interfaces';
import type { AngleRange } from '../interfaces.js';
export declare function distance(x1: number, y1: number, x2: number, y2: number): number;
export declare function inAngleRanges(x1: number, y1: number, x2: number, y2: number, angleRanges: AngleRange[] | undefined): boolean;
{
"name": "react-dnd-touch-backend",
"version": "15.0.2",
"version": "15.1.0",
"description": "Touch backend for react-dnd",
"main": "dist/cjs/index.js",
"module": "dist/esm/index.js",
"types": "dist/types/index.d.ts",
"exports": {
"import": "./dist/esm/index.mjs",
"require": "./dist/cjs/index.js",
"types": "./dist/types/index.d.ts"
},
"sideEffects": false,

@@ -20,7 +24,8 @@ "license": "MIT",

"build_cjs": "swc -C module.type=commonjs -d dist/cjs src/",
"build": "run-s build_types build_esm build_cjs"
"esm_hack": "node ../../scripts/esmify.mjs",
"build": "run-s build_types build_esm build_cjs esm_hack"
},
"dependencies": {
"@react-dnd/invariant": "^2.0.0",
"dnd-core": "15.0.2"
"dnd-core": "15.1.0"
},

@@ -30,2 +35,3 @@ "devDependencies": {

"@swc/core": "^1.2.136",
"@types/jest": "^27.4.0",
"npm-run-all": "^4.1.5",

@@ -32,0 +38,0 @@ "shx": "^0.3.4",

import type { DragDropManager, BackendFactory } from 'dnd-core'
import type { TouchBackendOptions, TouchBackendContext } from './interfaces'
import { TouchBackendImpl } from './TouchBackendImpl'
import type { TouchBackendOptions, TouchBackendContext } from './interfaces.js'
import { TouchBackendImpl } from './TouchBackendImpl.js'
export * from './interfaces'
export * from './TouchBackendImpl'
export * from './interfaces.js'
export * from './TouchBackendImpl.js'

@@ -8,0 +8,0 @@ export const TouchBackend: BackendFactory = function createBackend(

@@ -5,3 +5,3 @@ import type {

TouchBackendContext,
} from './interfaces'
} from './interfaces.js'

@@ -8,0 +8,0 @@ export class OptionsReader implements TouchBackendOptions {

@@ -16,3 +16,3 @@ import { invariant } from '@react-dnd/invariant'

TouchBackendContext,
} from './interfaces'
} from './interfaces.js'
import {

@@ -22,7 +22,7 @@ eventShouldStartDrag,

isTouchEvent,
} from './utils/predicates'
import { getEventClientOffset, getNodeClientOffset } from './utils/offsets'
import { distance, inAngleRanges } from './utils/math'
import { supportsPassive } from './utils/supportsPassive'
import { OptionsReader } from './OptionsReader'
} from './utils/predicates.js'
import { getEventClientOffset, getNodeClientOffset } from './utils/offsets.js'
import { distance, inAngleRanges } from './utils/math.js'
import { supportsPassive } from './utils/supportsPassive.js'
import { OptionsReader } from './OptionsReader.js'

@@ -29,0 +29,0 @@ const eventNames: Record<ListenerType, EventName> = {

@@ -1,2 +0,2 @@

import type { AngleRange } from '../interfaces'
import type { AngleRange } from '../interfaces.js'

@@ -3,0 +3,0 @@ export function distance(

import type { XYCoord } from 'dnd-core'
import { isTouchEvent } from './predicates'
import { isTouchEvent } from './predicates.js'

@@ -4,0 +4,0 @@ const ELEMENT_NODE = 1

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc