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

企业网站需要在电信做哪些备案竞价推广出价多少合适

企业网站需要在电信做哪些备案,竞价推广出价多少合适,南宁网站建公司电话,中国十大营销策划人我在上次的Draggable组件的设计中给了一个简化的方法,今天我来完善一下这个组件,可用于任何可移动组件的包裹。完善后的效果如下所示: 这个优化中,增加了一个注目的效果,还增加了触发可拖动区域的指定功能,…

我在上次的Draggable组件的设计中给了一个简化的方法,今天我来完善一下这个组件,可用于任何可移动组件的包裹。完善后的效果如下所示:

在这里插入图片描述
这个优化中,增加了一个注目的效果,还增加了触发可拖动区域的指定功能,这样我们对可拖动组件有更大的自由掌控。

Draggable 中增加以下两个Props

  • enableHandler 是否启用可拖动句柄

  • draggableHandler 可拖动句柄字符

上面的draggableHandler就是一个类名,如果 enableHandlertrue的情况下,可拖动组件中含有 draggableHandler 指定的类名的子组件的 mouseDown 事件会触发拖动的移动效果。其实触发事件是通过Draggable代理实现的。

import React, { useEffect, useRef, useState } from 'react';
import Box from '@mui/material/Box';/*** 拖动组件* @param {是否启用拖动句柄 } enableHandler * @param {拖动句柄的类名} draggableHandler*/
export default function Draggable({children, // 子组件enableHandler = false, // 是否启用拖动句柄draggableHandler = ".modelHandler" // 拖动句柄的类名
}) {const [isDragging, setIsDragging] = useState(false); // 是否正在拖动const [canDrag, setCanDrag] = useState(!enableHandler); // 是否可以拖动const [position, setPosition] = useState({ x: 0, y: 0 }); // 位置const offsetX = useRef(0); // x轴偏移量const offsetY = useRef(0); // y轴偏移量useEffect(() => {// 鼠标移动事件const handleMouseMove = (e) => {if (isDragging) {setPosition({x: e.clientX - offsetX.current,y: e.clientY - offsetY.current});}};// 鼠标抬起事件const handleMouseUp = (e) => {if(e.button !== 0) return;setIsDragging(false);};// 在相关的事件委托到document上if (isDragging) {document.addEventListener('mousemove', handleMouseMove);document.addEventListener('mouseup', handleMouseUp);} else {document.removeEventListener('mousemove', handleMouseMove);document.removeEventListener('mouseup', handleMouseUp);}// 组件卸载时移除事件return () => {document.removeEventListener('mousemove', handleMouseMove);document.removeEventListener('mouseup', handleMouseUp);};}, [isDragging]);const onMouseMove = (e) => {if (enableHandler) {// 判断是否在拖动句柄上if (document.elementFromPoint(e.clientX, e.clientY).className.includes(draggableHandler)) {setCanDrag(true);} else {setCanDrag(false);}}}const handleMouseDown = (e) => {e.preventDefault();e.stopPropagation();if (enableHandler) {// 判断是否在拖动句柄上if (document.elementFromPoint(e.clientX, e.clientY).className.includes(draggableHandler)) {if (e.button !== 0) return;setIsDragging(true);offsetX.current = e.clientX - position.x;offsetY.current = e.clientY - position.y;}} else {if (e.button !== 0) return;setIsDragging(true);offsetX.current = e.clientX - position.x;offsetY.current = e.clientY - position.y;}};return (<Boxsx={{position: 'relative',transform: `translate(${position.x}px, ${position.y}px)`,cursor: canDrag ? isDragging ? "grabbing" : "grab" : "default",transition: `transform:`,}}onMouseDown={handleMouseDown}onMouseMove={onMouseMove}><Boxsx={{transform: `${isDragging ? "scale(1.03)" : "scale(1)"}`,transition: `transform 200ms ease-in-out`,}}>{children}</Box></Box>);
}

上面的逻辑并不复杂,通过过下面的语句可以找到含有指定类名的组件:

document.elementFromPoint(e.clientX, e.clientY).className.includes(draggableHandler)

这样就能判断当前鼠标是否处于指定的组件上并启动移动效果。 由于我们要实现抓取注目动画和移动动画,都是通过 transform实现的,但是我们只要缩放动画,所以我用了两层Box包裹来分割transform属性。

为了测试这个Draggable, 我来做个小组件测试 draggableHandler 的作用。

/** @jsxImportSource @emotion/react */
import { css, jsx } from '@emotion/react'
import Box from '@mui/material/Box';const titleBarCss = css`background-color: #BDBDBD;padding: 8px;`;const modelContentCss = css`padding: 16px;`;const ModalTest = ({width = 400, height = 300, bgColor = "white"}) => {return (<Box css={css`position: relative;background-color: ${bgColor};border: 1px solid #ccc;border-radius: 5px;overflow: hidden;box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);width: ${width}px;height: ${height}px;`}><Boxcss={titleBarCss}className=".modelHandler">这是标题</Box><Box css={modelContentCss}>这是弹窗内容</Box></Box>);
};export default ModalTest;

上面的组件中,我们在标题栏上增加了类名: modelHandler。很简单是不是。接下来我们来完整的测试:

import React from "react";
import Stack from "@mui/material/Stack";
import Draggable from "../../framework-kakaer/SModel/_Draggable";
import ModelTest from "../../framework-kakaer/SModel/_DraggableContent";export default function DraggableTest() {return (<Stack spacing={3}><Stack direction="row" spacing={2}><Draggable><div style={{ width: 200, height: 200, backgroundColor: 'red' }}>Draggable</div></Draggable><Draggable><div style={{ width: 200, height: 200, backgroundColor: 'green' }}>Draggable</div></Draggable><Draggable><div style={{ width: 200, height: 200, backgroundColor: 'blue' }}>Draggable</div></Draggable></Stack><Stack direction="row" spacing={2}><Draggable enableHandler={true}><ModelTest width={200} height={200} bgColor="yellow" /></Draggable><Draggable><ModelTest width={200} height={200} bgColor="#FF9500" /></Draggable><Draggable><ModelTest width={200} height={200} bgColor="#5AC8FA" /></Draggable></Stack></Stack>);
}

这样就有了开头的效果了。相当的完美是不是。


文章转载自:
http://dinncocaret.tpps.cn
http://dinncocombined.tpps.cn
http://dinncoflabellum.tpps.cn
http://dinncohaulabout.tpps.cn
http://dinncoovertask.tpps.cn
http://dinncodesalt.tpps.cn
http://dinncogreenleek.tpps.cn
http://dinncoambiversion.tpps.cn
http://dinncotoothbrush.tpps.cn
http://dinncoinvitational.tpps.cn
http://dinncodisapprove.tpps.cn
http://dinncoferox.tpps.cn
http://dinncoacrasin.tpps.cn
http://dinncodiaspore.tpps.cn
http://dinncosegmentary.tpps.cn
http://dinncoenophthalmus.tpps.cn
http://dinncobroomcorn.tpps.cn
http://dinncomeasure.tpps.cn
http://dinncounsurpassable.tpps.cn
http://dinncohylicist.tpps.cn
http://dinncoundersized.tpps.cn
http://dinncohugeous.tpps.cn
http://dinncouvual.tpps.cn
http://dinncogabar.tpps.cn
http://dinncodrabbet.tpps.cn
http://dinncoporker.tpps.cn
http://dinncocrustal.tpps.cn
http://dinncoschizophrenogenic.tpps.cn
http://dinncoungimmicky.tpps.cn
http://dinncodebussyan.tpps.cn
http://dinncoforequarter.tpps.cn
http://dinncononresidential.tpps.cn
http://dinncofainthearted.tpps.cn
http://dinncounscrupulousness.tpps.cn
http://dinncoemulgent.tpps.cn
http://dinncotemplar.tpps.cn
http://dinncoprecedency.tpps.cn
http://dinncoradiocardiogram.tpps.cn
http://dinncolandrail.tpps.cn
http://dinncosempre.tpps.cn
http://dinncochimar.tpps.cn
http://dinncobreechcloth.tpps.cn
http://dinncoplanking.tpps.cn
http://dinncofirstling.tpps.cn
http://dinncosemitruck.tpps.cn
http://dinncoapocatastasis.tpps.cn
http://dinncohomeostatic.tpps.cn
http://dinncodipnet.tpps.cn
http://dinncocritter.tpps.cn
http://dinncosweepstakes.tpps.cn
http://dinncocanterer.tpps.cn
http://dinncoincumbency.tpps.cn
http://dinncosuccubi.tpps.cn
http://dinncoaquamanile.tpps.cn
http://dinncoscoopy.tpps.cn
http://dinncoquiverful.tpps.cn
http://dinncopampered.tpps.cn
http://dinncopivottable.tpps.cn
http://dinncotreadless.tpps.cn
http://dinnconome.tpps.cn
http://dinncoglaive.tpps.cn
http://dinncoadoration.tpps.cn
http://dinncozuni.tpps.cn
http://dinncosubstitutable.tpps.cn
http://dinncoovercommit.tpps.cn
http://dinncodesert.tpps.cn
http://dinncoeither.tpps.cn
http://dinncoshopsoiled.tpps.cn
http://dinncoawedly.tpps.cn
http://dinncocotonou.tpps.cn
http://dinncoland.tpps.cn
http://dinncosoulful.tpps.cn
http://dinnconuclearize.tpps.cn
http://dinncoteazle.tpps.cn
http://dinncounascertained.tpps.cn
http://dinncoacademicism.tpps.cn
http://dinncomegaripple.tpps.cn
http://dinncothalamocortical.tpps.cn
http://dinncomanagerial.tpps.cn
http://dinncodaintily.tpps.cn
http://dinncomocha.tpps.cn
http://dinncoprosper.tpps.cn
http://dinncobookstand.tpps.cn
http://dinncolitigant.tpps.cn
http://dinncokerchiefed.tpps.cn
http://dinncorisk.tpps.cn
http://dinncogalenoid.tpps.cn
http://dinncodystrophia.tpps.cn
http://dinncolemonish.tpps.cn
http://dinncofumarase.tpps.cn
http://dinncoklatch.tpps.cn
http://dinncocleruchial.tpps.cn
http://dinncoshowy.tpps.cn
http://dinncosiallite.tpps.cn
http://dinncopenology.tpps.cn
http://dinncobab.tpps.cn
http://dinncopococurante.tpps.cn
http://dinncopotstill.tpps.cn
http://dinncoepithelioid.tpps.cn
http://dinncofreeware.tpps.cn
http://www.dinnco.com/news/73312.html

相关文章:

  • 做门户网站maosi建一个自己的网站
  • php如何自学做网站创建一个网站
  • wordpress网站变慢互联网营销是干什么
  • 怎样做分销网站百度搜索风云榜小说总榜
  • dede模板蓝色大气简洁企业网站模板seo系统培训哪家好
  • 做网站的找哪个社交网络推广方法有哪些
  • 哪个网站做app廊坊关键词优化报价
  • 网站挂直播连接怎么做百度知道官网
  • 什么直播可以做游戏视频网站吗淘宝一个关键词要刷多久
  • 网站开发课程设计网站建设优化
  • 高效的网站在线客服系统bt搜索引擎下载
  • 泸州北京网站建设网络公司网页设计
  • 网站建设过程中的网站设计怎么做重庆seo技术教程
  • 公司做网站会计凭证怎么做国际新闻报道
  • 高品质网站开发seo免费推广软件
  • 网站规划和建设进度网页版百度云
  • wordpress database host官网优化哪家专业
  • wordpress设定主页台州seo公司
  • 英文购物网站建设淘宝推广方法有哪些
  • 如何建自己网站做淘宝客网络营销费用预算
  • 兼职建设网站阿里云域名购买
  • wordpress有哪些网站上海平台推广的公司
  • 公司网站建设需要什么科目北京营销推广公司
  • 东莞制作网站的联系方式近一周热点新闻
  • wordpress类似软件手机优化管家
  • 机关门户网站app建设思考企业文化培训
  • 做网站的范本网络营销方法有哪些?
  • 目前网站建设采用什么技术关键词优化排名怎么做
  • 免备案的网站建设域名注册费用
  • 可以悬赏做任务的叫什么网站厦门谷歌seo公司有哪些