new Ycc.UI.ScrollerRect(option)
滚动区域UI
此UI只能为顶级UI
| Name | Type | Description | |||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
option |
object |
所有可配置的配置项
|
Extends
Members
-
anchorXnumber
-
UI对象的锚点坐标。相对坐标。相对于rect的x 锚点坐标主要用于图形的旋转、平移、缩放
-
anchorYnumber
-
UI对象的锚点坐标。相对坐标。相对于rect的y 锚点坐标主要用于图形的旋转、平移、缩放
-
baseUIYcc.UI
-
基础绘图UI
-
belongToYcc.Layer
-
UI所属的图层
-
contentHnumber
-
滚动内容的高
-
contentWnumber
-
滚动内容的宽
-
coordinatesnull
-
多边形点坐标的数组,为保证图形能够闭合,起点和终点必须相等
-
ctxnull
-
绘图环境
-
ctxCachenull
-
缓存的绘图环境
-
disableTypeObject
-
被禁用的事件类型。key为type,val为boolean
-
dpinumber
-
设备像素比
-
enableSwipeboolean
-
是否禁用滑动事件
-
fillboolean
-
是否填充
-
fillStylestring
-
颜色
-
ghostboolean
-
此区域默认为幽灵
-
idnumber
-
UI的唯一ID
-
isDrawIndexboolean
-
是否绘制点的下标
-
isShowRotateBeforeUIboolean
-
是否显示缩放之前的位置
-
lineWidthnumber
-
线条宽度
-
listenersObject
-
所有的监听器。key为type,val为listener数组。
-
namestring
-
UI实例的名字
-
noneZeroModenumber
-
光线投射模式 1-升级模式 2-普通模式
-
onclickfunction
-
点击 的监听。默认为null
-
oncomputeendfunction
-
计算属性后的hook
-
oncomputestartfunction
-
计算属性前的hook
-
ondragendfunction
-
拖拽结束 的监听。默认为null
-
ondraggingfunction
-
拖拽 的监听。默认为null
-
ondragstartfunction
-
拖拽开始 的监听。默认为null
-
onmousedownfunction
-
鼠标按下 的监听。默认为null
-
onmousemovefunction
-
鼠标移动 的监听。默认为null
-
onmouseoutfunction
-
鼠标移出 的监听。默认为null
-
onmouseoverfunction
-
鼠标移入 的监听。默认为null
-
onmouseupfunction
-
鼠标抬起 的监听。默认为null
-
onrenderendfunction
-
渲染后的hook
-
onrenderstartfunction
-
渲染前的hook
-
ontapfunction
-
点击事件 的监听。默认为null
-
ontouchendfunction
-
触摸结束 的监听。默认为null
-
ontouchmovefunction
-
触摸移动 的监听。默认为null
-
ontouchstartfunction
-
触摸开始 的监听。默认为null
-
opacitynumber
-
透明度
-
rectYcc.Math.Rect
-
UI的绘图区域
-
rectBgColorstring
-
容纳区的背景色
-
rectBorderColorstring
-
容纳区边框颜色
-
rectBorderWidthnumber
-
容纳区的边框宽度
-
rotationnumber
-
相对于锚点的旋转角度
-
selfRenderboolean
-
是否自身实时渲染,启用后,会实时重绘整个画布
-
showboolean
-
是否显示
-
stopAllEventboolean
-
只会阻止当前UI事件的触发,不会阻止其下面子元素事件的触发
-
stopEventBubbleUpboolean
-
不阻止事件传递
-
stopTypeObject
-
被阻止的事件类型。key为type,val为boolean
-
strokeStylestring
-
线条颜色
-
swipeAccelerationnumber
-
滑动事件加速度
-
swipeFrameCountnumber
-
滑动事件持续的帧数
-
swipeInitSpeednumber
-
滑动事件初始速度 满足公式 s = (swipeInitSpeed - swipeFrameCount)*swipeFrameCount
-
userDatanull
-
用户自定义的数据
-
readonlyxnumber
-
位置x
-
readonlyynumber
-
位置y
-
yccClass
-
构造器的引用,Ycc中的每个类都有此属性
Methods
-
addChild(ui)
-
重载基类方法
Name Type Description ui -
inherited addListener(type, listener)
-
添加某个类型的监听器
Name Type Description typestring listenerfunction -
克隆ui
Returns:
Type Description Ycc.UI -
inherited containDot(dot, noneZeroMode){boolean}
-
重载基类的包含某个点的函数,用于点击事件等的响应 两种方法: 方法一:经过该点的水平射线与多边形的焦点数,即Ray-casting Algorithm 方法二:某个点始终位于多边形逆时针向量的左侧、或者顺时针方向的右侧即可判断,算法名忘记了 此方法采用方法一,并假设该射线平行于x轴,方向为x轴正方向
Name Type Description dotYcc.Math.Dot 需要判断的点,绝对坐标 noneZeroModeNumber 是否noneZeroMode 1--启用 2--关闭 默认启用 从这个点引出一根“射线”,与多边形的任意若干条边相交,计数初始化为0,若相交处被多边形的边从左到右切过,计数+1,若相交处被多边形的边从右到左切过,计数-1,最后检查计数,如果是0,点在多边形外,如果非0,点在多边形内 Returns:
Type Description boolean -
inherited disableEvent(type)
-
禁止某个事件触发
Name Type Description type -
合并参数,只会合并对象中已存在的key
Name Type Description optionReturns:
Type Description Ycc.UI -
inherited getAbsolutePositionRect(){Ycc.Math.Rect}
-
获取能容纳当前UI的最小方形区域
Returns:
Type Description Ycc.Math.Rect -
inherited getDeepLevel()
-
获取当前UI在树结构中的深度
-
inherited getMaxContentInWidth(content, width){string}
-
给定宽度,获取能容纳的最长单行字符串
Name Type Description contentstring 文本内容 widthnumber 指定宽度 Returns:
Type Description string -
inherited init(layer)
-
在某个图层中初始化UI
Name Type Description layerLayer 图层 -
inherited isOutOfRect(rect)
-
判断当前区域在某个区域外
Name Type Description rectYcc.Math.Rect -
inherited isOutOfStage(){boolean}
-
判断ui是否存在于舞台之外,渲染时可以不予渲染 在compute之后使用,判断更准确
Returns:
Type Description boolean -
inherited removeChild(ui)
-
删除子ui
Name Type Description ui -
inherited removeListener(type, listener)
-
移除某个类型的监听器
Name Type Description typelistener -
inherited removeSelf()
-
删除自身。 若子类包含多个UI,需要重载
-
render()
-
绘制
-
inherited renderPath(ctx)
-
根据coordinates绘制路径 只绘制路径,不填充、不描边 继承的子类若不是多边形,需要重载此方法
开启离屏canvas后,此过程只会发生在离屏canvas中Name Type Description ctx离屏canvas的绘图环境 -
inherited renderRectBgColor(absoluteRect)
-
渲染容纳区rect的背景色
开启离屏canvas后,此过程只会发生在离屏canvas中Name Type Description absoluteRectYcc.Math.Rect 容纳区的绝对位置 -
inherited renderRectBorder(absoluteRect)
-
渲染容纳区rect的边框
开启离屏canvas后,此过程只会发生在离屏canvas中Name Type Description absoluteRectYcc.Math.Rect 容纳区的绝对位置 -
inherited resumeEvent(type)
-
恢复某个事件的触发
Name Type Description type -
inherited scaleAndRotate()
-
坐标系的缩放和旋转。 先缩放、再旋转。
- TODO
-
- 子类渲染前需要调用此方法
- 多边形替换rect后,此方法废弃,不再调用
-
inherited stop(type)
-
阻止某个事件类型继续传递
Name Type Description type -
inherited transformByRotate(dot){Ycc.Math.Dot}
-
根据当前的锚点、旋转角度获取某个点的转换之后的坐标
Name Type Description dotYcc.Math.Dot | Array.<Ycc.Math.Dot> 需要转换的点,该点为相对坐标,相对于当前UI的父级 Returns:
Type Description Ycc.Math.Dot 转换后的点,该点为绝对坐标 -
inherited transformToAbsolute(dotOrArr){Ycc.Math.Dot|Array.<Ycc.Math.Dot>}
-
根据图层坐标和UI位置坐标,将某个点的相对坐标(相对于UI的父级),转换为舞台的绝对坐标
Name Type Description dotOrArrYcc.Math.Dot | Array.<Ycc.Math.Dot> Returns:
Type Description Ycc.Math.Dot | Array.<Ycc.Math.Dot> -
inherited transformToLocal(dotOrArr){Ycc.Math.Dot|Array.<Ycc.Math.Dot>}
-
根据图层坐标和UI位置坐标,将某个点的绝对坐标,转换为相对于UI父级的相对坐标
Name Type Description dotOrArrYcc.Math.Dot | Array.<Ycc.Math.Dot> Returns:
Type Description Ycc.Math.Dot | Array.<Ycc.Math.Dot> -
inherited triggerListener(type, data)
-
触发某一类型的监听器
Name Type Description typedata -
冒泡触发UI的事件
Name Type Description typexyoriginEventycc事件所对应的原始事件 Returns:
Type Description Array.<Ycc.UI> 返回已触发事件的UI列表