@clayui/shared
Advanced tools
Comparing version 3.95.0 to 3.95.2
@@ -91,27 +91,24 @@ "use strict"; | ||
var deps = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [isOpen]; | ||
useIsomorphicLayoutEffect(function () { | ||
function alignElement() { | ||
if (triggerRef.current) { | ||
var _points = alignmentPosition; | ||
var alignElement = (0, _react.useCallback)(function () { | ||
if (triggerRef.current && ref.current) { | ||
var _points = alignmentPosition; | ||
if (typeof _points === 'number') { | ||
_points = getAlignPoints(_points); | ||
} | ||
if (typeof _points === 'number') { | ||
_points = getAlignPoints(_points); | ||
} | ||
if (ref.current) { | ||
(0, _doAlign.doAlign)({ | ||
offset: getOffset(_points), | ||
overflow: { | ||
adjustX: autoBestAlign, | ||
adjustY: autoBestAlign, | ||
alwaysByViewport: alignmentByViewport | ||
}, | ||
points: _points, | ||
sourceElement: ref.current, | ||
targetElement: triggerRef.current | ||
}); | ||
} | ||
} | ||
(0, _doAlign.doAlign)({ | ||
offset: getOffset(_points), | ||
overflow: { | ||
adjustX: autoBestAlign, | ||
adjustY: autoBestAlign, | ||
alwaysByViewport: alignmentByViewport | ||
}, | ||
points: _points, | ||
sourceElement: ref.current, | ||
targetElement: triggerRef.current | ||
}); | ||
} | ||
}, []); | ||
useIsomorphicLayoutEffect(function () { | ||
if (isOpen && triggerRef.current) { | ||
@@ -122,2 +119,8 @@ alignElement(); | ||
}, deps); | ||
useIsomorphicLayoutEffect(function () { | ||
if (isOpen && ref.current) { | ||
alignElement(); | ||
return (0, _observeRect.observeRect)(ref.current, alignElement); | ||
} | ||
}, deps); | ||
} |
{ | ||
"name": "@clayui/shared", | ||
"version": "3.95.0", | ||
"version": "3.95.2", | ||
"description": "ClayShared component", | ||
@@ -45,3 +45,3 @@ "license": "BSD-3-Clause", | ||
], | ||
"gitHead": "dd76267f73294196857e7ac7f70e70cd8f649cd1" | ||
"gitHead": "68ebdcf79dab1ba0af5846b23f64fb8776156df7" | ||
} |
@@ -6,3 +6,3 @@ /** | ||
import React, {useEffect, useLayoutEffect} from 'react'; | ||
import React, {useCallback, useEffect, useLayoutEffect} from 'react'; | ||
@@ -99,29 +99,25 @@ import {doAlign} from './doAlign'; | ||
) { | ||
useIsomorphicLayoutEffect(() => { | ||
function alignElement() { | ||
if (triggerRef.current) { | ||
let points = alignmentPosition; | ||
const alignElement = useCallback(() => { | ||
if (triggerRef.current && ref.current) { | ||
let points = alignmentPosition; | ||
if (typeof points === 'number') { | ||
points = getAlignPoints( | ||
points as keyof typeof ALIGN_INVERSE | ||
); | ||
} | ||
if (typeof points === 'number') { | ||
points = getAlignPoints(points as keyof typeof ALIGN_INVERSE); | ||
} | ||
if (ref.current) { | ||
doAlign({ | ||
offset: getOffset(points), | ||
overflow: { | ||
adjustX: autoBestAlign, | ||
adjustY: autoBestAlign, | ||
alwaysByViewport: alignmentByViewport, | ||
}, | ||
points, | ||
sourceElement: ref.current, | ||
targetElement: triggerRef.current, | ||
}); | ||
} | ||
} | ||
doAlign({ | ||
offset: getOffset(points), | ||
overflow: { | ||
adjustX: autoBestAlign, | ||
adjustY: autoBestAlign, | ||
alwaysByViewport: alignmentByViewport, | ||
}, | ||
points, | ||
sourceElement: ref.current, | ||
targetElement: triggerRef.current, | ||
}); | ||
} | ||
}, []); | ||
useIsomorphicLayoutEffect(() => { | ||
if (isOpen && triggerRef.current) { | ||
@@ -133,2 +129,10 @@ alignElement(); | ||
}, deps); | ||
useIsomorphicLayoutEffect(() => { | ||
if (isOpen && ref.current) { | ||
alignElement(); | ||
return observeRect(ref.current, alignElement); | ||
} | ||
}, deps); | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
177391
4970