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

@rc-component/trigger

Package Overview
Dependencies
Maintainers
4
Versions
84
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@rc-component/trigger - npm Package Compare versions

Comparing version 1.12.0 to 1.12.1

24

es/util.d.ts

@@ -13,3 +13,3 @@ import type { CSSMotionProps } from 'rc-motion';

export declare function collectScroller(ele: HTMLElement): HTMLElement[];
export declare function toNum(num: number): number;
export declare function toNum(num: number, defaultValue?: number): number;
export interface VisibleArea {

@@ -21,2 +21,24 @@ left: number;

}
/**
*
*
* **************************************
* * Border *
* * ************************** *
* * * * * *
* * B * * S * B *
* * o * * c * o *
* * r * Content * r * r *
* * d * * o * d *
* * e * * l * e *
* * r ******************** l * r *
* * * Scroll * *
* * ************************** *
* * Border *
* **************************************
*
*/
/**
* Get visible area of element
*/
export declare function getVisibleArea(initArea: VisibleArea, scrollerList?: HTMLElement[]): {

@@ -23,0 +45,0 @@ left: number;

@@ -53,8 +53,11 @@ import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";

var current = ele === null || ele === void 0 ? void 0 : ele.parentElement;
var scrollStyle = ['hidden', 'scroll', 'auto'];
var scrollStyle = ['hidden', 'scroll', 'clip', 'auto'];
while (current) {
var _getWin$getComputedSt = getWin(current).getComputedStyle(current),
overflowX = _getWin$getComputedSt.overflowX,
overflowY = _getWin$getComputedSt.overflowY;
if (scrollStyle.includes(overflowX) || scrollStyle.includes(overflowY)) {
overflowY = _getWin$getComputedSt.overflowY,
overflow = _getWin$getComputedSt.overflow;
if ([overflowX, overflowY, overflow].some(function (o) {
return scrollStyle.includes(o);
})) {
scrollerList.push(current);

@@ -67,4 +70,30 @@ }

export function toNum(num) {
return Number.isNaN(num) ? 1 : num;
var defaultValue = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
return Number.isNaN(num) ? defaultValue : num;
}
function getPxValue(val) {
return toNum(parseFloat(val), 0);
}
/**
*
*
* **************************************
* * Border *
* * ************************** *
* * * * * *
* * B * * S * B *
* * o * * c * o *
* * r * Content * r * r *
* * d * * o * d *
* * e * * l * e *
* * r ******************** l * r *
* * * Scroll * *
* * ************************** *
* * Border *
* **************************************
*
*/
/**
* Get visible area of element
*/
export function getVisibleArea(initArea, scrollerList) {

@@ -79,6 +108,8 @@ var visibleArea = _objectSpread({}, initArea);

var _getWin$getComputedSt2 = getWin(ele).getComputedStyle(ele),
position = _getWin$getComputedSt2.position;
if (position === 'static') {
return;
}
overflow = _getWin$getComputedSt2.overflow,
overflowClipMargin = _getWin$getComputedSt2.overflowClipMargin,
borderTopWidth = _getWin$getComputedSt2.borderTopWidth,
borderBottomWidth = _getWin$getComputedSt2.borderBottomWidth,
borderLeftWidth = _getWin$getComputedSt2.borderLeftWidth,
borderRightWidth = _getWin$getComputedSt2.borderRightWidth;
var eleRect = ele.getBoundingClientRect();

@@ -89,10 +120,35 @@ var eleOutHeight = ele.offsetHeight,

eleInnerWidth = ele.clientWidth;
var borderTopNum = getPxValue(borderTopWidth);
var borderBottomNum = getPxValue(borderBottomWidth);
var borderLeftNum = getPxValue(borderLeftWidth);
var borderRightNum = getPxValue(borderRightWidth);
var scaleX = toNum(Math.round(eleRect.width / eleOutWidth * 1000) / 1000);
var scaleY = toNum(Math.round(eleRect.height / eleOutHeight * 1000) / 1000);
var eleScrollWidth = (eleOutWidth - eleInnerWidth) * scaleX;
var eleScrollHeight = (eleOutHeight - eleInnerHeight) * scaleY;
var eleRight = eleRect.x + eleRect.width - eleScrollWidth;
var eleBottom = eleRect.y + eleRect.height - eleScrollHeight;
visibleArea.left = Math.max(visibleArea.left, eleRect.x);
visibleArea.top = Math.max(visibleArea.top, eleRect.y);
// Original visible area
var eleScrollWidth = (eleOutWidth - eleInnerWidth - borderLeftNum - borderRightNum) * scaleX;
var eleScrollHeight = (eleOutHeight - eleInnerHeight - borderTopNum - borderBottomNum) * scaleY;
// Cut border size
var scaledBorderTopWidth = borderTopNum * scaleY;
var scaledBorderBottomWidth = borderBottomNum * scaleY;
var scaledBorderLeftWidth = borderLeftNum * scaleX;
var scaledBorderRightWidth = borderRightNum * scaleX;
// Clip margin
var clipMarginWidth = 0;
var clipMarginHeight = 0;
if (overflow === 'clip') {
var clipNum = getPxValue(overflowClipMargin);
clipMarginWidth = clipNum * scaleX;
clipMarginHeight = clipNum * scaleY;
}
// Region
var eleLeft = eleRect.x + scaledBorderLeftWidth - clipMarginWidth;
var eleTop = eleRect.y + scaledBorderTopWidth - clipMarginHeight;
var eleRight = eleLeft + eleRect.width + 2 * clipMarginWidth - scaledBorderLeftWidth - scaledBorderRightWidth - eleScrollWidth;
var eleBottom = eleTop + eleRect.height + 2 * clipMarginHeight - scaledBorderTopWidth - scaledBorderBottomWidth - eleScrollHeight;
visibleArea.left = Math.max(visibleArea.left, eleLeft);
visibleArea.top = Math.max(visibleArea.top, eleTop);
visibleArea.right = Math.min(visibleArea.right, eleRight);

@@ -99,0 +155,0 @@ visibleArea.bottom = Math.min(visibleArea.bottom, eleBottom);

@@ -13,3 +13,3 @@ import type { CSSMotionProps } from 'rc-motion';

export declare function collectScroller(ele: HTMLElement): HTMLElement[];
export declare function toNum(num: number): number;
export declare function toNum(num: number, defaultValue?: number): number;
export interface VisibleArea {

@@ -21,2 +21,24 @@ left: number;

}
/**
*
*
* **************************************
* * Border *
* * ************************** *
* * * * * *
* * B * * S * B *
* * o * * c * o *
* * r * Content * r * r *
* * d * * o * d *
* * e * * l * e *
* * r ******************** l * r *
* * * Scroll * *
* * ************************** *
* * Border *
* **************************************
*
*/
/**
* Get visible area of element
*/
export declare function getVisibleArea(initArea: VisibleArea, scrollerList?: HTMLElement[]): {

@@ -23,0 +45,0 @@ left: number;

@@ -65,8 +65,11 @@ "use strict";

var current = ele === null || ele === void 0 ? void 0 : ele.parentElement;
var scrollStyle = ['hidden', 'scroll', 'auto'];
var scrollStyle = ['hidden', 'scroll', 'clip', 'auto'];
while (current) {
var _getWin$getComputedSt = getWin(current).getComputedStyle(current),
overflowX = _getWin$getComputedSt.overflowX,
overflowY = _getWin$getComputedSt.overflowY;
if (scrollStyle.includes(overflowX) || scrollStyle.includes(overflowY)) {
overflowY = _getWin$getComputedSt.overflowY,
overflow = _getWin$getComputedSt.overflow;
if ([overflowX, overflowY, overflow].some(function (o) {
return scrollStyle.includes(o);
})) {
scrollerList.push(current);

@@ -79,4 +82,30 @@ }

function toNum(num) {
return Number.isNaN(num) ? 1 : num;
var defaultValue = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
return Number.isNaN(num) ? defaultValue : num;
}
function getPxValue(val) {
return toNum(parseFloat(val), 0);
}
/**
*
*
* **************************************
* * Border *
* * ************************** *
* * * * * *
* * B * * S * B *
* * o * * c * o *
* * r * Content * r * r *
* * d * * o * d *
* * e * * l * e *
* * r ******************** l * r *
* * * Scroll * *
* * ************************** *
* * Border *
* **************************************
*
*/
/**
* Get visible area of element
*/
function getVisibleArea(initArea, scrollerList) {

@@ -91,6 +120,8 @@ var visibleArea = (0, _objectSpread2.default)({}, initArea);

var _getWin$getComputedSt2 = getWin(ele).getComputedStyle(ele),
position = _getWin$getComputedSt2.position;
if (position === 'static') {
return;
}
overflow = _getWin$getComputedSt2.overflow,
overflowClipMargin = _getWin$getComputedSt2.overflowClipMargin,
borderTopWidth = _getWin$getComputedSt2.borderTopWidth,
borderBottomWidth = _getWin$getComputedSt2.borderBottomWidth,
borderLeftWidth = _getWin$getComputedSt2.borderLeftWidth,
borderRightWidth = _getWin$getComputedSt2.borderRightWidth;
var eleRect = ele.getBoundingClientRect();

@@ -101,10 +132,35 @@ var eleOutHeight = ele.offsetHeight,

eleInnerWidth = ele.clientWidth;
var borderTopNum = getPxValue(borderTopWidth);
var borderBottomNum = getPxValue(borderBottomWidth);
var borderLeftNum = getPxValue(borderLeftWidth);
var borderRightNum = getPxValue(borderRightWidth);
var scaleX = toNum(Math.round(eleRect.width / eleOutWidth * 1000) / 1000);
var scaleY = toNum(Math.round(eleRect.height / eleOutHeight * 1000) / 1000);
var eleScrollWidth = (eleOutWidth - eleInnerWidth) * scaleX;
var eleScrollHeight = (eleOutHeight - eleInnerHeight) * scaleY;
var eleRight = eleRect.x + eleRect.width - eleScrollWidth;
var eleBottom = eleRect.y + eleRect.height - eleScrollHeight;
visibleArea.left = Math.max(visibleArea.left, eleRect.x);
visibleArea.top = Math.max(visibleArea.top, eleRect.y);
// Original visible area
var eleScrollWidth = (eleOutWidth - eleInnerWidth - borderLeftNum - borderRightNum) * scaleX;
var eleScrollHeight = (eleOutHeight - eleInnerHeight - borderTopNum - borderBottomNum) * scaleY;
// Cut border size
var scaledBorderTopWidth = borderTopNum * scaleY;
var scaledBorderBottomWidth = borderBottomNum * scaleY;
var scaledBorderLeftWidth = borderLeftNum * scaleX;
var scaledBorderRightWidth = borderRightNum * scaleX;
// Clip margin
var clipMarginWidth = 0;
var clipMarginHeight = 0;
if (overflow === 'clip') {
var clipNum = getPxValue(overflowClipMargin);
clipMarginWidth = clipNum * scaleX;
clipMarginHeight = clipNum * scaleY;
}
// Region
var eleLeft = eleRect.x + scaledBorderLeftWidth - clipMarginWidth;
var eleTop = eleRect.y + scaledBorderTopWidth - clipMarginHeight;
var eleRight = eleLeft + eleRect.width + 2 * clipMarginWidth - scaledBorderLeftWidth - scaledBorderRightWidth - eleScrollWidth;
var eleBottom = eleTop + eleRect.height + 2 * clipMarginHeight - scaledBorderTopWidth - scaledBorderBottomWidth - eleScrollHeight;
visibleArea.left = Math.max(visibleArea.left, eleLeft);
visibleArea.top = Math.max(visibleArea.top, eleTop);
visibleArea.right = Math.min(visibleArea.right, eleRight);

@@ -111,0 +167,0 @@ visibleArea.bottom = Math.min(visibleArea.bottom, eleBottom);

2

package.json
{
"name": "@rc-component/trigger",
"version": "1.12.0",
"version": "1.12.1",
"description": "base abstract trigger component for react",

@@ -5,0 +5,0 @@ "engines": {

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