AABB
AlignmentBehavior
ArriveBehavior
AStar
BFS
BoundingSphere
BVH
BVHNode
Cell
CellSpacePartitioning
CohesionBehavior
CompositeGoal
ConvexHull
Corridor
CostTable
DFS
Dijkstra
Edge
EntityManager
EvadeBehavior
EventDispatcher
Behavior
FollowPathBehavior
FuzzyAND
FuzzyCompositeTerm
FuzzyFAIRLY
FuzzyModule
FuzzyOR
FuzzyRule
FuzzySet
FuzzyTerm
FuzzyVariable
FuzzyVERY
GameEntity
Goal
GoalEvaluator
Graph
GraphUtils
HalfEdge
HeuristicPolicyDijkstra
HeuristicPolicyEuclid
HeuristicPolicyEuclidSquared
HeuristicPolicyManhattan
InterposeBehavior
LeftSCurveFuzzySet
LeftShoulderFuzzySet
LineSegment
Logger
MathUtils
Matrix3
Matrix4
MemoryRecord
MemorySystem
MeshGeometry
MessageDispatcher
MovingEntity
NavEdge
NavMesh
NavMeshLoader
NavNode
Node
NormalDistFuzzySet
OBB
ObstacleAvoidanceBehavior
OffsetPursuitBehavior
OnPathBehavior
Path
Plane
Polygon
Polyhedron
PriorityQueue
PursuitBehavior
Quaternion
Ray
RectangleTriggerRegion
Regular
RightSCurveFuzzySet
RightShoulderFuzzySet
SAT
SeekBehavior
SeparationBehavior
SingletonFuzzySet
Smoother
SphericalTriggerRegion
State
StateMachine
SteeringBehavior
SteeringManager
Task
TaskQueue
Telegram
Think
Time
TriangularFuzzySet
Trigger
TriggerRegion
Vector3
Vehicle
Version
WanderBehavior

tolerance

toleranceArriveBehavior对象在检测到新元素到达时的容忍度。当指定了tolerance时,ArriveBehavior对象将在元素出现后的一段时间内等待,以确保元素真正到达。

语法

var arrive = new ArriveBehavior(selector, callback, options);
arrive.tolerance = 1000; // 在1秒内等待元素到达

参数

  • tolerance:等待新元素到达的时间(以毫秒为单位)。可以是一个整数或一个浮点数。默认为0,即不等待。

示例

下面是一个设置了tolerance参数的简单示例:

var arrive = new ArriveBehavior('.new-element', function() {
  console.log('New element has arrived!');
}, {
  tolerance: 2000 // 在2秒内等待元素到达
});

在上面的示例中,ArriveBehavior对象将在元素出现后的2秒内等待,以确保元素真正到达。如果2秒钟内没有检测到新元素,ArriveBehavior对象将停止监视。如果检测到新元素,将执行回调函数并停止监视。

总结

toleranceArriveBehavior对象在检测到新元素到达时的容忍度。使用tolerance参数可以确保元素真正到达后再执行行为。默认情况下,tolerance为0,即不等待,立即执行行为。可以使用整数或浮点数指定tolerance参数的值,单位为毫秒。