Socket
Socket
Sign inDemoInstall

rc-motion

Package Overview
Dependencies
Maintainers
4
Versions
43
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

rc-motion - npm Package Compare versions

Comparing version 2.9.1 to 2.9.2

39

es/hooks/useStatus.js

@@ -6,2 +6,3 @@ import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";

import useState from "rc-util/es/hooks/useState";
import useSyncState from "rc-util/es/hooks/useSyncState";
import * as React from 'react';

@@ -40,10 +41,11 @@ import { useEffect, useRef } from 'react';

setAsyncVisible = _useState2[1];
var _useState3 = useState(STATUS_NONE),
var _useSyncState = useSyncState(STATUS_NONE),
_useSyncState2 = _slicedToArray(_useSyncState, 2),
getStatus = _useSyncState2[0],
setStatus = _useSyncState2[1];
var _useState3 = useState(null),
_useState4 = _slicedToArray(_useState3, 2),
status = _useState4[0],
setStatus = _useState4[1];
var _useState5 = useState(null),
_useState6 = _slicedToArray(_useState5, 2),
style = _useState6[0],
setStyle = _useState6[1];
style = _useState4[0],
setStyle = _useState4[1];
var currentStatus = getStatus();
var mountedRef = useRef(false);

@@ -64,6 +66,7 @@ var deadlineRef = useRef(null);

function updateMotionEndStatus() {
setStatus(STATUS_NONE, true);
setStatus(STATUS_NONE);
setStyle(null, true);
}
var onInternalMotionEnd = useEvent(function (event) {
var status = getStatus();
// Do nothing since not in any transition status.

@@ -114,5 +117,5 @@ // This may happen when `motionDeadline` trigger.

var eventHandlers = React.useMemo(function () {
return getEventHandlers(status);
}, [status]);
var _useStepQueue = useStepQueue(status, !supportMotion, function (newStep) {
return getEventHandlers(currentStatus);
}, [currentStatus]);
var _useStepQueue = useStepQueue(currentStatus, !supportMotion, function (newStep) {
// Only prepare step can be skip

@@ -132,3 +135,3 @@ if (newStep === STEP_PREPARE) {

}
if (step === STEP_ACTIVE && status !== STATUS_NONE) {
if (step === STEP_ACTIVE && currentStatus !== STATUS_NONE) {
// Patch events when motion needed

@@ -200,7 +203,7 @@ patchMotionEvents(getDomElement());

// Cancel appear
status === STATUS_APPEAR && !motionAppear ||
currentStatus === STATUS_APPEAR && !motionAppear ||
// Cancel enter
status === STATUS_ENTER && !motionEnter ||
currentStatus === STATUS_ENTER && !motionEnter ||
// Cancel leave
status === STATUS_LEAVE && !motionLeave) {
currentStatus === STATUS_LEAVE && !motionLeave) {
setStatus(STATUS_NONE);

@@ -223,3 +226,3 @@ }

}
if (asyncVisible !== undefined && status === STATUS_NONE) {
if (asyncVisible !== undefined && currentStatus === STATUS_NONE) {
// Skip first render is invisible since it's nothing changed

@@ -231,3 +234,3 @@ if (firstMountChangeRef.current || asyncVisible) {

}
}, [asyncVisible, status]);
}, [asyncVisible, currentStatus]);

@@ -241,3 +244,3 @@ // ============================ Styles ============================

}
return [status, step, mergedStyle, asyncVisible !== null && asyncVisible !== void 0 ? asyncVisible : visible];
return [currentStatus, step, mergedStyle, asyncVisible !== null && asyncVisible !== void 0 ? asyncVisible : visible];
}

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

var _rcUtil = require("rc-util");
var _useState7 = _interopRequireDefault(require("rc-util/lib/hooks/useState"));
var _useState5 = _interopRequireDefault(require("rc-util/lib/hooks/useState"));
var _useSyncState3 = _interopRequireDefault(require("rc-util/lib/hooks/useSyncState"));
var _react = _interopRequireWildcard(require("react"));

@@ -46,14 +47,15 @@ var React = _react;

// Used for outer render usage to avoid `visible: false & status: none` to render nothing
var _useState = (0, _useState7.default)(),
var _useState = (0, _useState5.default)(),
_useState2 = (0, _slicedToArray2.default)(_useState, 2),
asyncVisible = _useState2[0],
setAsyncVisible = _useState2[1];
var _useState3 = (0, _useState7.default)(_interface.STATUS_NONE),
var _useSyncState = (0, _useSyncState3.default)(_interface.STATUS_NONE),
_useSyncState2 = (0, _slicedToArray2.default)(_useSyncState, 2),
getStatus = _useSyncState2[0],
setStatus = _useSyncState2[1];
var _useState3 = (0, _useState5.default)(null),
_useState4 = (0, _slicedToArray2.default)(_useState3, 2),
status = _useState4[0],
setStatus = _useState4[1];
var _useState5 = (0, _useState7.default)(null),
_useState6 = (0, _slicedToArray2.default)(_useState5, 2),
style = _useState6[0],
setStyle = _useState6[1];
style = _useState4[0],
setStyle = _useState4[1];
var currentStatus = getStatus();
var mountedRef = (0, _react.useRef)(false);

@@ -74,6 +76,7 @@ var deadlineRef = (0, _react.useRef)(null);

function updateMotionEndStatus() {
setStatus(_interface.STATUS_NONE, true);
setStatus(_interface.STATUS_NONE);
setStyle(null, true);
}
var onInternalMotionEnd = (0, _rcUtil.useEvent)(function (event) {
var status = getStatus();
// Do nothing since not in any transition status.

@@ -124,5 +127,5 @@ // This may happen when `motionDeadline` trigger.

var eventHandlers = React.useMemo(function () {
return getEventHandlers(status);
}, [status]);
var _useStepQueue = (0, _useStepQueue3.default)(status, !supportMotion, function (newStep) {
return getEventHandlers(currentStatus);
}, [currentStatus]);
var _useStepQueue = (0, _useStepQueue3.default)(currentStatus, !supportMotion, function (newStep) {
// Only prepare step can be skip

@@ -142,3 +145,3 @@ if (newStep === _interface.STEP_PREPARE) {

}
if (step === _interface.STEP_ACTIVE && status !== _interface.STATUS_NONE) {
if (step === _interface.STEP_ACTIVE && currentStatus !== _interface.STATUS_NONE) {
// Patch events when motion needed

@@ -210,7 +213,7 @@ patchMotionEvents(getDomElement());

// Cancel appear
status === _interface.STATUS_APPEAR && !motionAppear ||
currentStatus === _interface.STATUS_APPEAR && !motionAppear ||
// Cancel enter
status === _interface.STATUS_ENTER && !motionEnter ||
currentStatus === _interface.STATUS_ENTER && !motionEnter ||
// Cancel leave
status === _interface.STATUS_LEAVE && !motionLeave) {
currentStatus === _interface.STATUS_LEAVE && !motionLeave) {
setStatus(_interface.STATUS_NONE);

@@ -233,3 +236,3 @@ }

}
if (asyncVisible !== undefined && status === _interface.STATUS_NONE) {
if (asyncVisible !== undefined && currentStatus === _interface.STATUS_NONE) {
// Skip first render is invisible since it's nothing changed

@@ -241,3 +244,3 @@ if (firstMountChangeRef.current || asyncVisible) {

}
}, [asyncVisible, status]);
}, [asyncVisible, currentStatus]);

@@ -251,3 +254,3 @@ // ============================ Styles ============================

}
return [status, step, mergedStyle, asyncVisible !== null && asyncVisible !== void 0 ? asyncVisible : visible];
return [currentStatus, step, mergedStyle, asyncVisible !== null && asyncVisible !== void 0 ? asyncVisible : visible];
}
{
"name": "rc-motion",
"version": "2.9.1",
"version": "2.9.2",
"description": "React lifecycle controlled motion library",

@@ -51,3 +51,3 @@ "keywords": [

"classnames": "^2.2.1",
"rc-util": "^5.39.3"
"rc-util": "^5.43.0"
},

@@ -54,0 +54,0 @@ "devDependencies": {

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