首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >框架运动whileInView在移动设备上没有正确的动画

框架运动whileInView在移动设备上没有正确的动画
EN

Stack Overflow用户
提问于 2022-04-21 01:38:58
回答 1查看 1.5K关注 0票数 0

当切换到基于android的设备的移动视图或使用基于铬的移动仿真器时,在向下滚动视图之前,动画将处于完全状态。

此问题不会出现在Safari或桌面视图中。

在安装组件时显示在屏幕外的网站上使用的示例代码。

代码语言:javascript
复制
                <motion.div
                    variants={slideLeft(false)}
                    initial="initial"
                    whileInView="animate"
                    exit="exit"
                    transition={{ duration: 0.5 }}
                    viewport={{ once: true }}
                >

使用的动画变体

代码语言:javascript
复制
/**
 * @param {boolean} cont default: true
 * @param {boolean} exit default: true
 * @param {string} customVal default: %
 * @return {import("framer-motion").MotionProps}
 */
const slideLeft = (cont = true, exit = true, customVal = "%") => {
    /**
     * @type {import("framer-motion").MotionProps}
     */
    const output = {
        initial: {
            x: `100${customVal}`,
        },
        animate: {
            x: 0,
        },
        exit: {
            x: `-100${customVal}`,
        },
    };
    if (!cont) output.exit = { x: `100${customVal}` };
    if (!exit) delete output.exit;
    return output;
};
export default slideLeft;
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2022-04-21 01:38:58

当x轴(设备的右侧)出现溢出时,就会出现此问题.

可以通过应用此CSS样式来修复。overflow-x: hidden;

代码语言:javascript
复制
html,
body,
#root {
    height: 100%;
    width: 100%;
    margin: 0;
    padding: 0;
    /* Prevents overflow on the x-axis */
    overflow-x: hidden;
}
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/71947984

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档