当前位置: 首页 > wzjs >正文

做视频网站盈利多少外贸推广软件

做视频网站盈利多少,外贸推广软件,中劵资本集团股票交易网站建设中,网站 数据库motion 组件&#xff1a;为 HTML 和 SVG 元素赋予动画能力 motion 对象是 Framer Motion 的核心&#xff0c;它是一个标签工厂函数。你可以使用它来创建能够进行动画和手势交互的 HTML 和 SVG 元素。其基本语法是 motion.<HTMLTag /> 或 motion.<SVGTag />。 1. …

在这里插入图片描述

motion 组件:为 HTML 和 SVG 元素赋予动画能力

motion 对象是 Framer Motion 的核心,它是一个标签工厂函数。你可以使用它来创建能够进行动画和手势交互的 HTML 和 SVG 元素。其基本语法是 motion.<HTMLTag />motion.<SVGTag />

1. HTML 元素

你可以将任何标准的 HTML 标签替换为 motion 对应的版本,从而使其具备动画能力。以下是一些常用的 HTML 元素及其 motion 版本:

  • <div> -> <motion.div />
  • <span> -> <motion.span />
  • <button> -> <motion.button />
  • <img> -> <motion.img />
  • <a> -> <motion.a />
  • <ul> -> <motion.ul />
  • <li> -> <motion.li />
  • <input> -> <motion.input />
  • <textarea> -> <motion.textarea />
  • <label> -> <motion.label />
  • <form> -> <motion.form />
  • 等等…

用法示例 (针对不同 HTML 元素):

import { motion } from "framer-motion";
import { useState } from "react";function MotionHTMLElements() {const [isOpen, setIsOpen] = useState(false);return (<div style={{ display: "flex", flexDirection: "column", gap: 20 }}><motion.divinitial={{ opacity: 0, y: -20 }}animate={{ opacity: 1, y: 0 }}transition={{ duration: 0.5 }}style={{width: 200,height: 100,backgroundColor: "lightblue",display: "flex",justifyContent: "center",alignItems: "center",}}>Motion Div</motion.div><motion.spaninitial={{ scale: 0.8 }}animate={{ scale: 1.2 }}transition={{ type: "spring", stiffness: 300 }}style={{ fontSize: "1.5em", fontWeight: "bold" }}>Motion Span</motion.span><motion.buttonwhileHover={{ scale: 1.1 }}whileTap={{ scale: 0.9 }}style={{ padding: 10, backgroundColor: "lightcoral", color: "white", border: "none", borderRadius: 5, cursor: "pointer" }}onClick={() => setIsOpen(!isOpen)}>Motion Button</motion.button>{isOpen && (<motion.ulinitial={{ height: 0, opacity: 0 }}animate={{ height: "auto", opacity: 1 }}exit={{ height: 0, opacity: 0 }}transition={{ duration: 0.3 }}style={{ border: "1px solid #ccc", padding: 10 }}><motion.li>Item 1</motion.li><motion.li>Item 2</motion.li><motion.li>Item 3</motion.li></motion.ul>)}</div>);
}export default MotionHTMLElements;

正如你所见,你可以像使用普通的 HTML 标签一样使用 motion 版本,并为其添加 Framer Motion 特有的动画属性 (initial, animate, transition, whileHover, whileTap, exit 等)。

2. SVG 元素

Framer Motion 也支持对 SVG 元素进行动画。你可以使用 motion 对象创建可动画的 SVG 元素:

  • <svg> -> <motion.svg />
  • <path> -> <motion.path />
  • <circle> -> <motion.circle />
  • <rect> -> <motion.rect />
  • <line> -> <motion.line />
  • <polygon> -> <motion.polygon />
  • <polyline> -> <motion.polyline />
  • <ellipse> -> <motion.ellipse />
  • <text> -> <motion.text />
  • <g> -> <motion.g />
  • 等等…

SVG 动画示例 (路径绘制):

import { motion } from "framer-motion";
import { useState, useEffect, useRef } from "react";function MotionSVGElement() {const pathRef = useRef(null);const [pathLength, setPathLength] = useState(0);useEffect(() => {if (pathRef.current) {setPathLength(pathRef.current.getTotalLength());}}, []);return (<motion.svg width="200" height="200" viewBox="0 0 200 200"><motion.pathref={pathRef}d="M50,50 C70,10 130,10 150,50 C180,70 180,130 150,150 C130,190 70,190 50,150 C20,130 20,70 50,50"fill="none"stroke="blue"strokeWidth="3"initial={{ pathLength: 0, opacity: 0 }}animate={{ pathLength: 1, opacity: 1 }}transition={{ duration: 2, ease: "easeInOut" }}style={{ pathLength }} // 需要将 pathLength 应用到 style 上/><motion.circle cx="100" cy="100" r="10" fill="red" /></motion.svg>);
}export default MotionSVGElement;

在这个例子中,我们使用 <motion.path /> 来绘制一个心形曲线。通过动画 pathLength 属性,我们可以实现路径的绘制动画效果。注意,对于一些 SVG 特有的属性(如 pathLength, pathOffset),你可能需要将其作为 style 属性传递,以便 Framer Motion 正确地处理。

核心动画属性回顾 (适用于所有 motion 组件):

  • initial: 定义组件的初始状态。
  • animate: 定义组件要动画到的目标状态。可以是一个包含样式属性的对象,也可以是 variants 中定义的状态名称。
  • exit: 定义组件卸载时的动画状态 (通常与 <AnimatePresence /> 组件一起使用)。
  • transition: 控制动画的过渡效果,包括 duration (持续时间), ease (缓动函数), delay (延迟), type (动画类型: tween, spring, inertia), repeat (重复次数), repeatType (loop, reverse, mirror), repeatDelay (重复延迟) 等。
  • variants: 一个对象,用于定义组件的不同动画状态 (例如 "initial", "visible", "hidden", "hovered", "pressed" 等)。你可以在 initial, animate, exit 和事件处理属性中引用这些变体名称。
  • 事件处理属性 (用于交互):
    • whileHover: 定义鼠标悬停时的动画状态。
    • whileTap: 定义鼠标点击 (按下和释放) 时的动画状态。
    • whileDrag: 定义拖拽时的动画状态 (需要设置 drag 属性为 true)。
    • onHoverStart, onHoverEnd, onTap, onTapCancel, onDragStart, onDrag, onDragEnd, onPan, onPanStart, onPanEnd 等事件回调函数。
  • drag: 设置为 true 使元素可以被拖拽。可以指定拖拽的方向 ("x", "y") 和边界 (dragConstraints).
  • layout: 用于在布局更改时创建平滑的动画过渡 (Layout Animations)。

总结:

motion 组件是 Framer Motion 的基石,通过将标准的 HTML 和 SVG 元素包裹在 motion.<Tag /> 中,你可以轻松地为其添加各种动画和交互效果。关键在于理解和使用这些丰富的动画属性,以及如何将它们与 variants, useMotionValue, useTransform<AnimatePresence /> 等其他 Framer Motion 功能结合起来,创建出复杂而流畅的用户界面动画。记住,几乎所有的视觉属性都可以通过 Framer Motion 进行动画控制,尽情发挥你的创造力吧!


文章转载自:

http://ZoQGytdW.rshkh.cn
http://ne9KXWt9.rshkh.cn
http://kpo0jSby.rshkh.cn
http://vUEFUKKD.rshkh.cn
http://vY92QL1V.rshkh.cn
http://MziLS0za.rshkh.cn
http://9iwblxlj.rshkh.cn
http://HIsLkoz4.rshkh.cn
http://XNjFZrjZ.rshkh.cn
http://LNKyxlyV.rshkh.cn
http://VewVCSTZ.rshkh.cn
http://rdeDYiuw.rshkh.cn
http://ozNT2g12.rshkh.cn
http://v7V5bQfx.rshkh.cn
http://Sp6FDxBK.rshkh.cn
http://x3v2LF1Y.rshkh.cn
http://LMM7PUZ8.rshkh.cn
http://1uACAr0N.rshkh.cn
http://oCbGEL6d.rshkh.cn
http://5FB0C4Gd.rshkh.cn
http://ktKFaYZq.rshkh.cn
http://RVsIHtgu.rshkh.cn
http://DGaD0M9h.rshkh.cn
http://hVZLDlr0.rshkh.cn
http://kzIpZX6F.rshkh.cn
http://QOhq0uob.rshkh.cn
http://pf5gvBHK.rshkh.cn
http://BILZw8q0.rshkh.cn
http://RIHLE1PP.rshkh.cn
http://apY3Ueir.rshkh.cn
http://www.dtcms.com/wzjs/695848.html

相关文章:

  • 价格划算的做网站python网站开发的优势
  • 与wordpress类似的都有哪些谷歌优化推广
  • html5 响应式网站wordpress 纯静态
  • 个人网站主页设计站群seo
  • 景乔网站建设网站公司怎么做
  • 网站建设捌金手指花总十七免费装修设计效果图
  • 深圳手机集团网站建设贵阳建站模板搭建
  • 网站建设赚钱吗北京市公共资源交易服务平台
  • 北海建设网站东坑做网站
  • 搭建网站需要钱吗网站建设中哪些最重要性
  • 江苏茂盛建设有限公司网站网站在线优化检测
  • 国内知名域名注册网站wordpress 连接qq视频教程
  • 网站推广产品哪个网站免费建站最好
  • 网站建设中单页源码华为的网络营销方式
  • 搞网站海淘网站入口
  • 浙江省专业网站制作网站建设国内it外包龙头企业
  • 高端的网站推广成都网站专业制作
  • 建设银行网站是多少广州公司关键词网络推广
  • 网站建设与发布需要什么公司微信网站开发平台
  • 姑苏营销型网站建设电话网站修改字体尺寸怎么做
  • 如何看一个网站是否做推广有哪些专门做校企合作的网站
  • 优化网站被百度屏淮北招聘网
  • 做俄罗斯生意网站平台app如何推广
  • 网站建设教程推荐莱芜论坛莱芜话题
  • 做网站的用什么电脑好网站建设的前后台代码
  • 用微信怎么做企业网站广州网站建设讯度
  • 母婴类网站怎么建设长沙关键词优化方法
  • 南平网站开发公司管理客户的免费软件
  • 网站容量js做示爱网站例子
  • 福州高端网站建设服务网络公司西安未央网站建设