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

@dflex/core-instance

Package Overview
Dependencies
Maintainers
1
Versions
63
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@dflex/core-instance - npm Package Compare versions

Comparing version 3.0.0 to 3.1.0

dist/AbstractInstance.d.ts

21

dist/CoreInstance.d.ts

@@ -1,9 +0,12 @@

import AbstractCoreInstance from "./AbstractCoreInstance";
import type { Keys, Order, CoreInstanceInterface, Rect, TransitionHistory, CoreInput } from "./types";
declare class CoreInstance extends AbstractCoreInstance implements CoreInstanceInterface {
offset?: Rect;
import { AxesCoordinates } from "@dflex/utils";
import type { Rect } from "@dflex/utils";
import AbstractInstance from "./AbstractInstance";
import type { Keys, Order, TransitionHistory, CoreInput, AbstractOpts, CoreInstanceInterface } from "./types";
declare class CoreInstance extends AbstractInstance implements CoreInstanceInterface {
offset: Rect;
/** Store history of Y-transition according to unique ID. */
prevTranslateY?: TransitionHistory;
currentTop?: number;
currentLeft?: number;
translateHistory?: AxesCoordinates<TransitionHistory>;
currentPosition?: AxesCoordinates;
currentTop: number;
currentLeft: number;
order: Order;

@@ -15,3 +18,3 @@ keys: Keys;

animatedFrame: number | null;
constructor(elementWithPointer: CoreInput);
constructor(elementWithPointer: CoreInput, opts: AbstractOpts);
/**

@@ -28,2 +31,4 @@ * Initializes the element offset only when it's called. Since it is sorting

private updateCurrentIndicators;
isPositionedUnder(elmY: number): boolean;
isPositionedLeft(elmX: number): boolean;
transformElm(): void;

@@ -30,0 +35,0 @@ updateDataset(i: number): void;

"use strict";
/* eslint-disable no-param-reassign */
var __extends = (this && this.__extends) || (function () {

@@ -33,17 +32,19 @@ var extendStatics = function (d, b) {

Object.defineProperty(exports, "__esModule", { value: true });
var AbstractCoreInstance_1 = __importDefault(require("./AbstractCoreInstance"));
/* eslint-disable no-param-reassign */
var utils_1 = require("@dflex/utils");
var AbstractInstance_1 = __importDefault(require("./AbstractInstance"));
var CoreInstance = /** @class */ (function (_super) {
__extends(CoreInstance, _super);
function CoreInstance(elementWithPointer) {
function CoreInstance(elementWithPointer, opts) {
var _this = this;
var order = elementWithPointer.order, keys = elementWithPointer.keys, depth = elementWithPointer.depth, scrollX = elementWithPointer.scrollX, scrollY = elementWithPointer.scrollY, element = __rest(elementWithPointer, ["order", "keys", "depth", "scrollX", "scrollY"]);
_this = _super.call(this, element) || this;
_this = _super.call(this, element, opts) || this;
_this.order = order;
_this.keys = keys;
_this.depth = depth;
_this.isVisible = element.isInitialized && !element.isPaused;
if (element.isInitialized) {
_this.isVisible = _this.isInitialized && !_this.isPaused;
if (_this.isInitialized) {
_this.updateDataset(_this.order.self);
}
if (!element.isPaused) {
if (!_this.isPaused) {
_this.initIndicators(scrollX, scrollY);

@@ -62,5 +63,2 @@ }

CoreInstance.prototype.initIndicators = function (scrollX, scrollY) {
if (!Array.isArray(this.prevTranslateY)) {
this.prevTranslateY = [];
}
var _a = this.ref.getBoundingClientRect(), height = _a.height, width = _a.width, left = _a.left, top = _a.top;

@@ -78,2 +76,3 @@ /**

};
this.currentPosition = new utils_1.AxesCoordinates(left, top);
this.currentTop = this.offset.top;

@@ -98,5 +97,4 @@ this.currentLeft = this.offset.left;

};
CoreInstance.prototype.updateCurrentIndicators = function (topSpace, leftSpace) {
this.translateY += topSpace;
this.translateX += leftSpace;
CoreInstance.prototype.updateCurrentIndicators = function (leftSpace, topSpace) {
this.translate.setAxes(this.translate.x + leftSpace, this.translate.y + topSpace);
var _a = this.offset, left = _a.left, top = _a.top;

@@ -107,7 +105,14 @@ /**

*/
this.currentTop = top + this.translateY;
this.currentLeft = left + this.translateX;
this.currentPosition.setAxes(left + this.translate.x, top + this.translate.y);
this.currentTop = top + this.translate.y;
this.currentLeft = left + this.translate.x;
if (!this.isVisible)
this.hasToTransform = true;
};
CoreInstance.prototype.isPositionedUnder = function (elmY) {
return elmY < this.currentTop;
};
CoreInstance.prototype.isPositionedLeft = function (elmX) {
return elmX < this.currentLeft;
};
CoreInstance.prototype.transformElm = function () {

@@ -119,3 +124,3 @@ var _this = this;

this.animatedFrame = window.requestAnimationFrame(function () {
_this.ref.style.transform = "translate3d(".concat(_this.translateX, "px,").concat(_this.translateY, "px, 0)");
_this.ref.style.transform = "translate3d(".concat(_this.translate.x, "px,").concat(_this.translate.y, "px, 0)");
_this.animatedFrame = null;

@@ -178,8 +183,18 @@ });

if (operationID) {
this.prevTranslateY.push({
var historyY = {
ID: operationID,
translateY: this.translateY,
});
pre: this.translate.y,
};
if (!this.translateHistory) {
var historyX = {
ID: operationID,
pre: this.translate.x,
};
this.translateHistory = new utils_1.AxesCoordinates([historyX], [historyY]);
}
else {
this.translateHistory.y.push(historyY);
}
}
this.updateCurrentIndicators(topSpace, 0);
this.updateCurrentIndicators(0, topSpace);
if (!isForceTransform && !this.isVisible) {

@@ -227,8 +242,9 @@ this.hasToTransform = true;

CoreInstance.prototype.rollYBack = function (operationID, isForceTransform) {
if (this.prevTranslateY.length === 0 ||
this.prevTranslateY[this.prevTranslateY.length - 1].ID !== operationID) {
if (this.translateHistory.y.length === 0 ||
this.translateHistory.y[this.translateHistory.y.length - 1].ID !==
operationID) {
return;
}
var translateY = this.prevTranslateY.pop().translateY;
var topSpace = translateY - this.translateY;
var pre = this.translateHistory.y.pop().pre;
var topSpace = pre - this.translate.y;
var increment = topSpace > 0 ? 1 : -1;

@@ -242,3 +258,3 @@ // Don't update UI if it's zero and wasn't transformed.

return CoreInstance;
}(AbstractCoreInstance_1.default));
}(AbstractInstance_1.default));
exports.default = CoreInstance;

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

export type { AbstractCoreInterface, Rect, TransitionHistory, CoreInstanceInterface, } from "./types";
export { default } from "./CoreInstance";
import CoreInstance from "./CoreInstance";
export type { AbstractInterface as AbstractCoreInterface, CoreInput, TransitionHistory, CoreInstanceInterface, } from "./types";
export default CoreInstance;

@@ -6,4 +6,3 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.default = void 0;
var CoreInstance_1 = require("./CoreInstance");
Object.defineProperty(exports, "default", { enumerable: true, get: function () { return __importDefault(CoreInstance_1).default; } });
var CoreInstance_1 = __importDefault(require("./CoreInstance"));
exports.default = CoreInstance_1.default;

@@ -1,27 +0,21 @@

interface AbsCoreEssential {
import { AxesCoordinates } from "@dflex/utils";
import type { Rect } from "@dflex/utils";
export interface AbstractOpts {
isInitialized: boolean;
isPaused: boolean;
}
export declare type AbstractInput = {
id: string;
isPaused?: boolean;
}
interface AbsCoreWithRef {
isInitialized: true;
ref: HTMLElement;
}
interface AbsCoreWithoutRef {
isInitialized: false;
ref: null;
}
export declare type AbstractCoreInput = (AbsCoreEssential & AbsCoreWithoutRef) | (AbsCoreEssential & AbsCoreWithRef);
export interface AbstractCoreInterface {
ref?: HTMLElement;
};
export interface AbstractInterface {
isInitialized: boolean;
isPaused: boolean;
ref: HTMLElement | null;
id: string;
isPaused: boolean;
isInitialized: boolean;
translateY?: number;
translateX?: number;
initTranslate(): void;
translate: AxesCoordinates;
attach(ref: HTMLElement | null): void;
detach(): void;
hasValidRef(): void;
initTranslate(): void;
}
export declare type ELmBranch = string | string[];
/**

@@ -49,3 +43,3 @@ * Element unique keys in DOM tree.

}
export interface CoreEssential {
export interface CoreInput extends AbstractInput {
order: Order;

@@ -57,18 +51,13 @@ keys: Keys;

}
export declare type CoreInput = CoreEssential & AbstractCoreInput;
export interface Rect {
height: number;
width: number;
left: number;
top: number;
}
export declare type TransitionHistory = {
ID: string;
translateY: number;
pre: number;
}[];
export interface CoreInstanceInterface extends AbstractCoreInterface {
offset?: Rect;
prevTranslateY?: TransitionHistory;
currentTop?: number;
currentLeft?: number;
export interface CoreInstanceInterface extends AbstractInterface {
isVisible: boolean;
offset: Rect;
translateHistory?: AxesCoordinates<TransitionHistory>;
currentPosition?: AxesCoordinates;
readonly currentTop: number;
readonly currentLeft: number;
order: Order;

@@ -78,9 +67,11 @@ keys: Keys;

animatedFrame: number | null;
isPositionedUnder(elmY: number): boolean;
isPositionedLeft(elmX: number): boolean;
resume(scrollX: number, scrollY: number): void;
changeVisibility(isVisible: boolean): void;
setYPosition(iDsInOrder: ELmBranch, sign: 1 | -1, topSpace: number, operationID: string, siblingsHasEmptyElm?: number, vIncrement?: number, isShuffle?: boolean): void;
setYPosition(iDsInOrder: string[], sign: 1 | -1, topSpace: number, operationID: string, siblingsHasEmptyElm?: number, vIncrement?: number, isShuffle?: boolean): number;
transformElm(): void;
assignNewPosition(branchIDsOrder: string[], newIndex: number, oldIndex?: number, siblingsHasEmptyElm?: number): number;
updateDataset(index: number): void;
rollYBack(operationID: string, isForceTransform: boolean): void;
}
export {};
"use strict";
/* eslint-disable no-unused-vars */
Object.defineProperty(exports, "__esModule", { value: true });
{
"name": "@dflex/core-instance",
"version": "3.0.0",
"version": "3.1.0",
"main": "dist/index.js",
"types": "dist/index.d.ts",
"author": "Jalal Maskoun <jimmy002020@gmail.com>",
"author": "Jalal Maskoun",
"scripts": {

@@ -18,2 +18,5 @@ "compile": "yarn rimraf ./dist tsconfig.tsbuildinfo && yarn tsc -b",

],
"dependencies": {
"@dflex/utils": "^3.1.0"
},
"keywords": [

@@ -39,3 +42,3 @@ "drag-drop",

},
"gitHead": "8a604a4bbdfa2584879b6fd0da7d982a7b21b9aa"
"gitHead": "eac9f58fd4893166f1db260bc01a99fa8b641af3"
}

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