示例#1
0
		/// <summary>Looks for any element with the 'draggable' attribute.</summary>
		public static Element GetDraggable(Element current){
			
			while(current!=null){
				
				// Got the attribute?
				if(current.getAttribute("draggable")!=null){
					return current;
				}
				
				current=current.parentElement;
			}
			
			// Nope!
			return null;
			
		}
        /// <summary>Finds the minimum drag distance. Always greater than zero.</summary>
        public float GetMinDragDistance()
        {
            // If we've got a 'draggable' element, that is preferred:
            Element draggable = ((ActiveUpdatingTarget == null)?ActivePressedTarget : ActiveUpdatingTarget) as Element;

            if (draggable == null)
            {
                return(Input.MinimumDragStartDistance);
            }

            float distance = draggable.DragStartDistance;

            if (distance == 0f)
            {
                // Default, (after checking for a mindrag attribute):
                string minDrag = draggable.getAttribute("mindrag");

                if (minDrag == null)
                {
                    // Unspecified.
                    // Default depends if we're actually a 'draggable' or not:
                    if (ActiveUpdatingTarget == null)
                    {
                        distance = Input.MinimumDragStartDistance;
                    }
                    else
                    {
                        // 1:
                        distance = 1f;
                    }
                }
                else if (!float.TryParse(minDrag, out distance) || distance <= 0f)
                {
                    // Default:
                    distance = Input.MinimumDragStartDistance;
                }
            }

            return(distance);
        }