@rpg-engine/long-bow 0.8.230 → 0.8.231

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -3738,26 +3738,35 @@ var ItemTooltip = function ItemTooltip(_ref) {
3738
3738
  atlasJSON = _ref.atlasJSON,
3739
3739
  equipmentSet = _ref.equipmentSet;
3740
3740
  var ref = React.useRef(null);
3741
+ var rafId = React.useRef(null);
3741
3742
  React.useEffect(function () {
3742
3743
  var current = ref.current;
3743
3744
  if (current) {
3744
3745
  var handleMouseMove = function handleMouseMove(event) {
3746
+ if (rafId.current !== null) return;
3745
3747
  var clientX = event.clientX,
3746
3748
  clientY = event.clientY;
3747
- // Adjust the position of the tooltip based on the mouse position
3748
- var rect = current.getBoundingClientRect();
3749
- var tooltipWidth = rect.width;
3750
- var tooltipHeight = rect.height;
3751
- var isOffScreenRight = clientX + tooltipWidth + offset > window.innerWidth;
3752
- var isOffScreenBottom = clientY + tooltipHeight + offset > window.innerHeight;
3753
- var x = isOffScreenRight ? clientX - tooltipWidth - offset : clientX + offset;
3754
- var y = isOffScreenBottom ? clientY - tooltipHeight - offset : clientY + offset;
3755
- current.style.transform = "translate(" + x + "px, " + y + "px)";
3756
- current.style.opacity = '1';
3749
+ rafId.current = requestAnimationFrame(function () {
3750
+ rafId.current = null;
3751
+ // Adjust the position of the tooltip based on the mouse position
3752
+ var rect = current.getBoundingClientRect();
3753
+ var tooltipWidth = rect.width;
3754
+ var tooltipHeight = rect.height;
3755
+ var isOffScreenRight = clientX + tooltipWidth + offset > window.innerWidth;
3756
+ var isOffScreenBottom = clientY + tooltipHeight + offset > window.innerHeight;
3757
+ var x = isOffScreenRight ? clientX - tooltipWidth - offset : clientX + offset;
3758
+ var y = isOffScreenBottom ? clientY - tooltipHeight - offset : clientY + offset;
3759
+ current.style.transform = "translate(" + x + "px, " + y + "px)";
3760
+ current.style.opacity = '1';
3761
+ });
3757
3762
  };
3758
3763
  window.addEventListener('mousemove', handleMouseMove);
3759
3764
  return function () {
3760
3765
  window.removeEventListener('mousemove', handleMouseMove);
3766
+ if (rafId.current !== null) {
3767
+ cancelAnimationFrame(rafId.current);
3768
+ rafId.current = null;
3769
+ }
3761
3770
  };
3762
3771
  }
3763
3772
  return;
@@ -5363,6 +5372,7 @@ var SimpleTooltip = function SimpleTooltip(_ref) {
5363
5372
  var tooltipRef = React.useRef(null);
5364
5373
  var triggerRef = React.useRef(null);
5365
5374
  var timeoutRef = React.useRef();
5375
+ var rafId = React.useRef(null);
5366
5376
  var calculatePosition = function calculatePosition() {
5367
5377
  if (!triggerRef.current || !tooltipRef.current) return;
5368
5378
  var triggerRect = triggerRef.current.getBoundingClientRect();
@@ -5414,15 +5424,21 @@ var SimpleTooltip = function SimpleTooltip(_ref) {
5414
5424
  };
5415
5425
  React.useEffect(function () {
5416
5426
  var handleMouseMove = function handleMouseMove(event) {
5417
- if (visible && tooltipRef.current && triggerRef.current) {
5418
- var tooltipRect = tooltipRef.current.getBoundingClientRect();
5419
- var triggerRect = triggerRef.current.getBoundingClientRect();
5420
- var isOutsideTooltip = event.clientX < tooltipRect.left || event.clientX > tooltipRect.right || event.clientY < tooltipRect.top || event.clientY > tooltipRect.bottom;
5421
- var isOutsideTrigger = event.clientX < triggerRect.left || event.clientX > triggerRect.right || event.clientY < triggerRect.top || event.clientY > triggerRect.bottom;
5422
- if (isOutsideTooltip && isOutsideTrigger) {
5423
- hideTooltip();
5427
+ if (rafId.current !== null) return;
5428
+ var clientX = event.clientX,
5429
+ clientY = event.clientY;
5430
+ rafId.current = requestAnimationFrame(function () {
5431
+ rafId.current = null;
5432
+ if (visible && tooltipRef.current && triggerRef.current) {
5433
+ var tooltipRect = tooltipRef.current.getBoundingClientRect();
5434
+ var triggerRect = triggerRef.current.getBoundingClientRect();
5435
+ var isOutsideTooltip = clientX < tooltipRect.left || clientX > tooltipRect.right || clientY < tooltipRect.top || clientY > tooltipRect.bottom;
5436
+ var isOutsideTrigger = clientX < triggerRect.left || clientX > triggerRect.right || clientY < triggerRect.top || clientY > triggerRect.bottom;
5437
+ if (isOutsideTooltip && isOutsideTrigger) {
5438
+ hideTooltip();
5439
+ }
5424
5440
  }
5425
- }
5441
+ });
5426
5442
  };
5427
5443
  var handleScroll = function handleScroll() {
5428
5444
  if (visible) {
@@ -5441,6 +5457,10 @@ var SimpleTooltip = function SimpleTooltip(_ref) {
5441
5457
  document.removeEventListener('mousemove', handleMouseMove);
5442
5458
  window.removeEventListener('scroll', handleScroll);
5443
5459
  window.removeEventListener('resize', handleResize);
5460
+ if (rafId.current !== null) {
5461
+ cancelAnimationFrame(rafId.current);
5462
+ rafId.current = null;
5463
+ }
5444
5464
  clearTimeout(timeoutRef.current);
5445
5465
  };
5446
5466
  }, [visible]);