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

网站做点线表格wordpress访问速度太慢

网站做点线表格,wordpress访问速度太慢,沈阳行业网站建设,东莞做网站定制展示效果 原理: 当停止滑动时 判断Contet的horizontalNormalizedPosition 与子Item的缓存值 相减,并得到最小值#xff0c;然后将Content horizontalNormalizedPosition滚动过去 使用方式#xff1a; 直接将脚本挂到ScrollRect上 注意#xff1a;在创建Content子物体时…展示效果 原理: 当停止滑动时 判断Contet的horizontalNormalizedPosition 与子Item的缓存值 相减,并得到最小值然后将Content  horizontalNormalizedPosition滚动过去 使用方式 直接将脚本挂到ScrollRect上 注意在创建Content子物体时 或子物体数量变更需要调用Refresh 代码 namespace ShangShangQian.Component {using System.Collections;using System.Collections.Generic;using UnityEngine;using UnityEngine.UI;using UnityEngine.EventSystems;using System.Linq;using UnityEngine.Events;[RequireComponent(typeof(ScrollRect))]public class SnapScrollRect : MonoBehaviour, IBeginDragHandler, IDragHandler, IEndDragHandler{private RectTransform content;private ScrollRect rect;/// summary/// content 的位置应该滚到什么/// /summarypublic float target 1;/// summary/// 回滚的速度 0-1 越小越快/// /summarypublic float smooting 0.25f;public float currentVelocity;public float horizontalNormalizedPosition;public Listfloat values new Listfloat();public Listfloat distances new Listfloat();public ListRectTransform items new ListRectTransform();/// summary/// 是否拖拽中/// /summarypublic bool isDrag false;/// summary/// 到最近item的距离/// /summarypublic float distanceMin;/// summary/// 到最近item的索引/// /summarypublic int selectIndex;/// summary/// 是否匹配滑动中/// /summarypublic bool Snaping false;/// summary/// 回滚完毕后调用/// /summarypublic UnityEventint OnSnap;void Start(){rect GetComponentScrollRect();content rect.content;}/// summary/// 刷新数据content的子物体数量变更时需要调用此函数/// /summarypublic void Refresh(){items.Clear();values.Clear();for (int i 0; i content.childCount; i){if (content.GetChild(i).gameObject.activeInHierarchy){items.Add(content.GetChild(i).GetComponentRectTransform());}}//累加的变量values.Add(0);//每一个格子的所占比多少 float v 1f / (items.Count - 1);for (int i 1; i items.Count; i){values.Add(i * v);}//不同子元素数量 item 对应 的content horizontalNormalizedPosition 数值//1 0 //2 0 1 //3 0 0.5 1//4 0 0.33 0.66 1}void Update(){ #if UNITY_EDITORif (Input.GetKeyDown(KeyCode.A)){Refresh();} #endif}void FixedUpdate(){horizontalNormalizedPosition rect.horizontalNormalizedPosition;if (isDrag){return;}if (Snaping){rect.horizontalNormalizedPosition Mathf.SmoothDamp(rect.horizontalNormalizedPosition, target, ref currentVelocity, smooting);if (Mathf.Abs(rect.horizontalNormalizedPosition - values[selectIndex]) 0.001f){Snaping false;Debug.Log(回滚: selectIndex);OnSnap.Invoke(selectIndex);}}}public void OnBeginDrag(PointerEventData eventData){isDrag true;}public void OnDrag(PointerEventData eventData){isDrag true;}public void OnEndDrag(PointerEventData eventData){isDrag false;Snaping true;distances.Clear();//当松手后判断那个距离最近for (int i 0; i values.Count; i){distances.Add(Mathf.Abs(rect.horizontalNormalizedPosition - values[i]));}distanceMin distances.Min();selectIndex distances.FindIndex(b b distanceMin);target values[selectIndex];rect.StopMovement();}/// summary/// 滚到到指定位置/// /summary/// param nameindex/parampublic void SnapToIndex(int index){Snaping true;selectIndex index;target values[selectIndex];}} }
http://www.hkea.cn/news/14373588/

相关文章:

  • seo网站排名全选朋友要给我做网站
  • 网站建设的收费天眼查询企业信息系统
  • 做视频直播网站wordpress发号系统
  • 网站建设提案怎么写部队织梦网站模板免费下载
  • 做网站需要什么软件教程三类人不适合学编程plc
  • 好玩的网站源码安卓集成wordpress
  • 亿万网站做坏事小视频网站
  • seo网站优化插件做公众号试卷的网站
  • 贵州城乡住房建设网站wordpress中htaccess
  • 谷德设计网站企业网站手机端模板
  • 广西南宁网站建设有什么网站是可以做ui的
  • 老地方在线观看免费资源大全东莞seo网站管理
  • 中间商网站怎么做公司网站自己创建
  • 犀牛云网站做的怎么样火车头7.6 wordpress发布模块
  • 制作微信公众号的网站开发如何在腾讯云建设网站
  • 单页网站怎么做深圳网站制作工具
  • 怎样做才能让自己的网站做网站找哪家
  • 制作网站的基本流程网站顶部轮播怎么做
  • 青岛网站平台开发网上学编程哪个培训班最好
  • 四川做网站的公司有哪些政协网站建设方案
  • 知名购物网站有哪些wordpress 文章点击排行
  • 网站建设费 科研 类怎么制作网址
  • 专门做配电箱的网站河南第一火电建设公司网站
  • 南宁做网站外包体彩网站建设
  • 建设网站如何给页面命名泰安网站建设优化案例报告
  • 北京 高端网站设计网络营销课程总结与心得体会
  • 成都市建设厅官方网站海口制作网站公司
  • 济南微网站开发自己做网站帮公司出认证证书违法吗
  • 教育培训网站模板下载网站开发哪家公司电话
  • 济南营销型网站建设公司网站建设流程知乎