New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@bestminr/drag-base

Package Overview
Dependencies
Maintainers
2
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@bestminr/drag-base - npm Package Compare versions

Comparing version 0.0.4-alpha.0 to 0.0.4

35

dist/drag-base.common.js

@@ -17,5 +17,7 @@ 'use strict';

};
let timer = undefined;
let dragging = false;
let globalPayload;
const onButtonDown = function (event, payload) {
if (onButtonDown.timer)
const startDrag = function (event, payload) {
if (timer)
return;

@@ -26,3 +28,3 @@ if (before)

event.preventDefault();
if (onButtonDown.dragging)
if (dragging)
return;

@@ -35,9 +37,7 @@ globalPayload = payload;

scrollContainer.addEventListener('scroll', onScroll);
onButtonDown.timer = setTimeout(() => {
timer = window.setTimeout(() => {
onDragStart(event);
onButtonDown.timer = undefined;
timer = undefined;
}, delay);
};
onButtonDown.dragging = false;
onButtonDown.timer = undefined;
function getTop(top) {

@@ -66,5 +66,5 @@ if (typeof maxHeight === 'number') {

function onDragStart(event) {
if (onButtonDown.dragging)
if (dragging)
return;
onButtonDown.dragging = true;
dragging = true;
const { clientX, clientY } = event;

@@ -80,3 +80,3 @@ dargData.x = clientX;

function onDragging(event) {
if (!onButtonDown.dragging)
if (!dragging)
return;

@@ -96,6 +96,6 @@ const { clientX, clientY } = event;

function onDragEnd(event, { isCancelling } = {}) {
if (!onButtonDown.dragging && !onButtonDown.timer)
if (!dragging && !timer)
return;
setTimeout(() => {
onButtonDown.dragging = false;
dragging = false;
dargData.x = 0;

@@ -121,5 +121,5 @@ dargData.y = 0;

scrollContainer.removeEventListener('scroll', onScroll);
if (onButtonDown.timer) {
clearTimeout(onButtonDown.timer);
onButtonDown.timer = undefined;
if (timer) {
clearTimeout(timer);
timer = undefined;
}

@@ -141,4 +141,7 @@ }

return {
onButtonDown,
startDrag,
cancel,
get isDragging() {
return dragging;
},
};

@@ -145,0 +148,0 @@ }

@@ -13,5 +13,7 @@ const isServer = typeof window === 'undefined';

};
let timer = undefined;
let dragging = false;
let globalPayload;
const onButtonDown = function (event, payload) {
if (onButtonDown.timer)
const startDrag = function (event, payload) {
if (timer)
return;

@@ -22,3 +24,3 @@ if (before)

event.preventDefault();
if (onButtonDown.dragging)
if (dragging)
return;

@@ -31,9 +33,7 @@ globalPayload = payload;

scrollContainer.addEventListener('scroll', onScroll);
onButtonDown.timer = setTimeout(() => {
timer = window.setTimeout(() => {
onDragStart(event);
onButtonDown.timer = undefined;
timer = undefined;
}, delay);
};
onButtonDown.dragging = false;
onButtonDown.timer = undefined;
function getTop(top) {

@@ -62,5 +62,5 @@ if (typeof maxHeight === 'number') {

function onDragStart(event) {
if (onButtonDown.dragging)
if (dragging)
return;
onButtonDown.dragging = true;
dragging = true;
const { clientX, clientY } = event;

@@ -76,3 +76,3 @@ dargData.x = clientX;

function onDragging(event) {
if (!onButtonDown.dragging)
if (!dragging)
return;

@@ -92,6 +92,6 @@ const { clientX, clientY } = event;

function onDragEnd(event, { isCancelling } = {}) {
if (!onButtonDown.dragging && !onButtonDown.timer)
if (!dragging && !timer)
return;
setTimeout(() => {
onButtonDown.dragging = false;
dragging = false;
dargData.x = 0;

@@ -117,5 +117,5 @@ dargData.y = 0;

scrollContainer.removeEventListener('scroll', onScroll);
if (onButtonDown.timer) {
clearTimeout(onButtonDown.timer);
onButtonDown.timer = undefined;
if (timer) {
clearTimeout(timer);
timer = undefined;
}

@@ -137,4 +137,7 @@ }

return {
onButtonDown,
startDrag,
cancel,
get isDragging() {
return dragging;
},
};

@@ -141,0 +144,0 @@ }

{
"name": "@bestminr/drag-base",
"version": "0.0.4-alpha.0",
"version": "0.0.4",
"description": "",

@@ -26,3 +26,4 @@ "keywords": [],

"devDependencies": {
"jest": "*"
"jest": "*",
"typescript": "^3.3.3"
},

@@ -33,4 +34,3 @@ "sideEffects": false,

"access": "public"
},
"gitHead": "650c2887f655389164c1e64c96c11034aa51dbe7"
}
}

@@ -9,3 +9,3 @@ export declare type DargData = {

};
export declare type CreateDragFunction<T> = {
export declare type CreateDragFunctionOpts<T> = {
maxHeight?: number;

@@ -28,9 +28,11 @@ maxWidth?: number;

};
export declare function createDragFunction<T = any>({ maxHeight, maxWidth, before, start, doing, end, canceled, finally: onFinally, minHeight, minWidth, scrollContainer, delay, }: CreateDragFunction<T>): {
onButtonDown: {
(event: MouseEvent, payload: T): void;
dragging: boolean;
timer: any;
};
export declare function createDragFunction<T = any>({ maxHeight, maxWidth, before, start, doing, end, canceled, finally: onFinally, minHeight, minWidth, scrollContainer, delay, }: CreateDragFunctionOpts<T>): {
startDrag: (event: MouseEvent, payload: T) => void;
cancel: (event?: MouseEvent) => void;
readonly isDragging: boolean;
};
/**
*
* 此种写法无法推断出需要额外 createDragFunction<T> 的 T 类型
*/
export declare type DragContext = ReturnType<typeof createDragFunction>;
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