小编vis*_*Inc的帖子

如何使用 Framer Motion <AnimatePresence> 和 React Portal?

情况

我使用React Portals构建了一个 React Modal组件(请参阅上面的文档)。在单击关闭按钮时卸载组件之前,我想使用AnimatePresence通过 Framer Motion 运行动画。不幸的是,我无法让它发挥作用,需要帮助。exit

链接

我尝试过的

我添加exit={{ opacity: 0 }}了一个孩子<RenderModal/>。输入动画使用initial并按animate预期工作。

  1. 环绕<AnimatePresence>模态根元素
<div id="root"></div>
<AnimatePresence>
  <div id="modal-root"></div>
</AnimatePresence>
Run Code Online (Sandbox Code Playgroud)
  1. 包装为 modal-root 的子级

错误:目标容器需要 DOM 元素

<div id="modal-root">
  <AnimatePresence></AnimatePresence>
</div>
Run Code Online (Sandbox Code Playgroud)
  1. 环绕组件元素
const Modal = ({
    title,
    footer,
    children,
  }) => {
   <AnimatePresence>
    {isVisible
      && (
        <RenderModal
          title={title}
          footer={footer}
          hide={hide}
        >
          {children}
        </RenderModal>
      )}
    </AnimatePresence>
  };
Run Code Online (Sandbox Code Playgroud)
  1. 包裹使用过的组件
return …
Run Code Online (Sandbox Code Playgroud)

javascript animation reactjs framer-motion

7
推荐指数
2
解决办法
5217
查看次数

使用 otree 时出现“pip install -U Channels”命令错误(运行 setup.py bdist_wheel for twins ... 错误)

对于使用 otree ( http://otree.readthedocs.io/ )的项目,我在尝试安装时遇到了一些问题Channels以使用实时功能时遇到了一些问题。

由于输出很长,我试图找出最重要的部分:

有关完整输出,请参阅:https://jsfiddle.net/L4ccmr2k/1/

红色标记的输出和我认为相关的输出:

1.

 Building wheels for collected packages: twisted
      Running setup.py bdist_wheel for twisted ... error
Run Code Online (Sandbox Code Playgroud)

2.

creating build/temp.macosx-10.6-intel-3.6
      creating build/temp.macosx-10.6-intel-3.6/src
      creating build/temp.macosx-10.6-intel-3.6/src/twisted
      creating build/temp.macosx-10.6-intel-3.6/src/twisted/test
      /usr/bin/clang -fno-strict-aliasing -Wsign-compare -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -arch i386 -arch x86_64 -g -I/Library/Frameworks/Python.framework/Versions/3.6/include/python3.6m -c src/twisted/test/raiser.c -o build/temp.macosx-10.6-intel-3.6/src/twisted/test/raiser.o
      xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools), missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun
      error: command '/usr/bin/clang' failed with exit status 1

      ----------------------------------------
      Failed building wheel for twisted …
Run Code Online (Sandbox Code Playgroud)

python django pip twisted python-wheel

5
推荐指数
1
解决办法
3553
查看次数

为什么画布在圆(弧)之间画线?

在当下画布绘制15个不同速度和大小的圆圈,从ltr移动.当其中一个离开窗口时,它将被设置为开始.问题是画布在圆圈之间划线,我不知道为什么?有人可以帮忙吗?

window.onload = function () {
    var canvas = document.getElementById('canvas');
    var ctx = canvas.getContext('2d');
    var W = canvas.width = window.innerWidth;
    var H = canvas.height = window.innerHeight;
    var mp = 15; //max particles
    var particles = [];
    //var rotate = 180;

    reqAnimFrame = window.requestAnimationFrame ||
                   window.mozRequestAnimationFrame    ||
                   window.webkitRequestAnimationFrame ||
                   window.msRequestAnimationFrame     ||
                   window.oRequestAnimationFrame;

    for ( var i = 0; i < mp; i++ )
        {
            particles.push({
                x: Math.floor(Math.random()*W), //x-coordinate
                y: Math.floor(Math.random()*H), //y-coordinate
                d: Math.floor(Math.random()*(mp - 1) + 1), //density
                r: Math.floor(Math.random()*(70 - …
Run Code Online (Sandbox Code Playgroud)

html javascript html5 animation canvas

1
推荐指数
1
解决办法
3298
查看次数