util
- Description:
Contains utility classes and methods used by geojs.
- Source:
Classes
Members
(static) cssAngleUnitsBase
- Description:
A dictionary of conversion factors for angular CSS measurements.
- Source:
A dictionary of conversion factors for angular CSS measurements.
(static) cssColorConversions
- Description:
A list of regex and processing functions for color conversions to rgb objects. Each entry is a
geo.util.cssColorConversionRecord
. In general, these conversions are somewhat more forgiving than the css specification (see https://drafts.csswg.org/css-color/) in that percentages may be mixed with numbers, and that floating point values are accepted for all numbers. Commas are optional. As per the latest draft standard,rgb
andrgba
are aliases of each other, as arehsl
andhsla
.
- Source:
Properties:
Name | Type | Description |
---|---|---|
cssColorConversions |
Array.<geo.util.cssColorConversionRecord> |
A list of regex and processing functions for color conversions to rgb
objects. Each entry is a geo.util.cssColorConversionRecord
. In
general, these conversions are somewhat more forgiving than the css
specification (see https://drafts.csswg.org/css-color/) in that
percentages may be mixed with numbers, and that floating point values are
accepted for all numbers. Commas are optional. As per the latest draft
standard, rgb
and rgba
are aliases of each other, as are hsl
and
hsla
.
(static) cssNumberRegex
- Description:
A regular expression string that will parse a number (integer or floating point) for CSS properties.
- Source:
A regular expression string that will parse a number (integer or floating point) for CSS properties.
(static) radiusEarth
- Description:
Radius of the earth in meters, from the equatorial radius of SRID 4326.
- Source:
Radius of the earth in meters, from the equatorial radius of SRID 4326.
Methods
(static) actionMatch(inputs, modifiers, actions) → {geo.actionRecord}
- Description:
Determine if the current inputs and modifiers match a known action.
- Source:
Parameters:
Name | Type | Description |
---|---|---|
inputs |
object | Aan object where each input that is currently
active is truthy. Common inputs are |
modifiers |
object | An object where each currently applied
modifier is truthy. Common modifiers are |
actions |
Array.<geo.actionRecord> | A list of actions to compare to the inputs and modifiers. The first action that matches will be returned. |
Returns:
A matching action or undefined
.
- Type
- geo.actionRecord
(static) addAction(actions, action, toEnd)
- Description:
Add an action to the list of handled actions.
- Source:
Parameters:
Name | Type | Description |
---|---|---|
actions |
Array.<geo.actionRecord> | An array of actions to adjust as needed. |
action |
geo.actionRecord | An object defining the action. Use
|
toEnd |
boolean | The action is added at the beginning of the
actions list unless |
(static) adjustActions(actions)
- Description:
Ensure that the input and modifiers properties of all actions are objects, not plain strings.
- Source:
Parameters:
Name | Type | Description |
---|---|---|
actions |
Array.<geo.actionRecord> | An array of actions to adjust as needed. |
(static) centerFromPerimeter(coor) → {geo.geoPosition|undefined}
- Description:
Return the coordinate associated with the center of the perimeter formed from a list of points. This averages all of the vertices in the perimeter weighted by the line length on either side of each point. Functionally, this is the same as the average of all the points of the lines of the perimeter.
- Source:
Parameters:
Name | Type | Description |
---|---|---|
coor |
geo.geoPolygon | An array of coordinates. This can also be
a polygon object with an |
Returns:
The position for the center, or
undefined
if no such position exists.
- Type
- geo.geoPosition | undefined
(static) compareArrays(a1, a2) → {boolean}
- Description:
Compare two arrays and return if their contents are equal.
- Source:
Parameters:
Name | Type | Description |
---|---|---|
a1 |
array | First array to compare. |
a2 |
array | Second array to compare. |
Returns:
true
if the contents of the arrays are equal.
- Type
- boolean
(static) convertColor(color) → {geo.geoColorObject}
- Description:
Convert a color to a standard rgb object. Allowed inputs:
- rgb object with optional 'a' (alpha) value.
- css color name
- #rrggbb, #rrggbbaa, #rgb, #rgba hexadecimal colors
- rgb(), rgba(), hsl(), and hsla() css colors
- transparent The output object always contains r, g, b on a scale of [0-1]. If an alpha value is specified, the output will also contain an 'a' value on a scale of [0-1]. Objects already in rgb format are not checked to make sure that all parameters are in the range of [0-1], but string inputs are so validated.
- Source:
Parameters:
Name | Type | Description |
---|---|---|
color |
geo.geoColor | Any valid color input. |
Returns:
An rgb color object, possibly with an 'a' value. If the input cannot be converted to a valid color, the input value is returned.
- Type
- geo.geoColorObject
(static) convertColorAndOpacity(coloropt, opacityopt, defaultColoropt) → {geo.geoColorObject}
- Description:
Convert a color (possibly with opacity) and an optional opacity value to a color object that always has opacity. The opacity is guaranteed to be within [0-1]. A valid color object is always returned.
- Source:
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
color |
geo.geoColor |
<optional> |
Any valid color input. If an invalid value
or no value is supplied, the |
|
opacity |
number |
<optional> |
1
|
A value from [0-1]. This is multiplied with
the opacity from |
defaultColor |
geo.geoColorObject |
<optional> |
{r: 0, g: 0, b: 0}
|
The color to use if an invalid color is supplied. |
Returns:
An rgba color object.
- Type
- geo.geoColorObject
(static) convertColorToHex(color, allowAlphaopt) → {string}
- Description:
Convert a color to a six or eight digit hex value prefixed with #.
- Source:
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
color |
geo.geoColorObject | The color object to convert. |
|
allowAlpha |
boolean |
<optional> |
If truthy and |
Returns:
A color string.
- Type
- string
(static) convertColorToRGBA(color) → {string}
- Description:
Convert a color to a css rgba() value.
- Source:
Parameters:
Name | Type | Description |
---|---|---|
color |
geo.geoColorObject | The color object to convert. |
Returns:
A color string.
- Type
- string
(static) createColoredMesh(feature, elementValues) → {geo.meshFeature.meshColoredInfo}
- Description:
Create a set of vertices, values at the vertices or elements, and opacities at the vertices or elements. Create a set of triangles of indices into the vertex array. Create a color and opacity map corresponding to the values.
- Source:
Parameters:
Name | Type | Description |
---|---|---|
feature |
geo.meshFeature | A mesh feature. |
elementValues |
boolean | Truthy to compute values and opacities at elements, falsy for vertices. |
Returns:
An object with the colored mesh information.
(static) crossedLineSegmentPolygon2d(pt1, pt2, poly) → {boolean}
- Description:
Determine if a line segment crosses any line segments of a polygon.
- Source:
Parameters:
Name | Type | Description |
---|---|---|
pt1 |
geo.geoPosition | One endpoint of the line. |
pt2 |
geo.geoPosition | The other endpoint of the line. |
poly |
geo.polygonObject | The polygon. |
Returns:
True if the segment cross any segment of the polygon.
- Type
- boolean
(static) crossedLineSegments2d(seg1pt1, seg1pt2, seg2pt1, seg2pt2) → {boolean}
- Description:
Determine if two line segments cross. They are not considered crossing if they share a vertex. They are crossing if either of one segment's vertices are collinear with the other segment.
- Source:
Parameters:
Name | Type | Description |
---|---|---|
seg1pt1 |
geo.geoPosition | One endpoint of the first segment. |
seg1pt2 |
geo.geoPosition | The other endpoint of the first segment. |
seg2pt1 |
geo.geoPosition | One endpoint of the second segment. |
seg2pt2 |
geo.geoPosition | The other endpoint of the second segment. |
Returns:
True if the segments cross.
- Type
- boolean
(static) debounce(delay, at_beginopt, callback, accumulatoropt) → {function}
- Description:
Debounce execution of a function. Debouncing, unlike throttling, guarantees that a function is only executed a single time, either at the very beginning of a series of calls, or at the very end. If you want to simply rate-limit execution of a function, see the <jQuery.throttle> method.
In this visualization, | is a debounced-function call and X is the actual callback execution:
::
Debounced with
at_begin
specified as false or unspecified: ||||||||||||||||||||||||| (pause) ||||||||||||||||||||||||| X XDebounced with
at_begin
specified as true: ||||||||||||||||||||||||| (pause) ||||||||||||||||||||||||| X XThe bulk of the work is handled by the
geo.util.throttle
function.
- Source:
Example
var debounced = geo.util.debounce( delay, [ at_begin, ] callback );
$('selector').bind( 'someevent', debounced );
$('selector').unbind( 'someevent', debounced );
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
delay |
number | A zero-or-greater delay in milliseconds. For event callbacks, values around 100 or 250 (or even higher) are most useful. |
||
at_begin |
boolean |
<optional> |
false
|
If at_begin is false or
unspecified, callback will only be executed |
callback |
function | A function to be executed after delay milliseconds.
The |
||
accumulator |
function |
<optional> |
A function to be executed (synchronously) during each call to the wrapped function. Typically, this this method is used to accumulate values that the callback uses when it finally executes. |
Returns:
A new, debounced, function.
- Type
- function
(static) deepMerge(target, sources) → {object}
- Description:
Recursively merge two objects. This is intended to replace util.deepMerge(target, ...sources).
- Source:
Parameters:
Name | Type | Description |
---|---|---|
target |
object | target object to modify. |
sources |
object | object(s) to merge into the target. |
Returns:
The merged object.
- Type
- object
(static) dereferenceCssUrls(css, styleElem, styleDefer, styleKeyopt, baseUrlopt)
- Description:
Check css text. Any url(http[s]...) references are dereferenced and stored as local base64 urls.
- Source:
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
css |
string | The css to parse for urls. |
|
styleElem |
jQuery.selector | HTMLElement | The element that receives the css text after dereferencing or the DOM element that has style that will be updated. |
|
styleDefer |
jQuery.Deferred | A Deferred to resolve once dereferencing is complete. |
|
styleKey |
string |
<optional> |
If unset, styleElem is a header element. If set, styleElem is a DOM element and the named style will be updated. |
baseUrl |
string |
<optional> |
If present, this is the base for relative urls. |
(static) dereferenceElements(elem) → {Array.<jQuery.Deferred>}
- Description:
Check svg image and html img tags. If the source is set, load images explicitly and convert them to local data:image references.
- Source:
Parameters:
Name | Type | Description |
---|---|---|
elem |
jQuery.selector | A jQuery selector or element set that may contain images. |
Returns:
A list of deferred objects that resolve when images are dereferenced.
- Type
- Array.<jQuery.Deferred>
(static) distance2dToLineSquared(pt, line1, line2) → {number}
- Description:
Get the square of the Euclidean 2D distance between a point and a line segment.
- Source:
Parameters:
Name | Type | Description |
---|---|---|
pt |
geo.geoPosition | The point. |
line1 |
geo.geoPosition | One end of the line. |
line2 |
geo.geoPosition | The other end of the line. |
Returns:
The distance squared.
- Type
- number
(static) distanceToPolygon2d(pt, poly, onlySignopt) → {number}
- Description:
Get the signed Euclidean 2D distance between a point and a polygon. The distance is positive if the point is inside of the polygon.
- Source:
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
pt |
geo.geoPosition | The point. |
|
poly |
geo.polygonObject | The polygon. |
|
onlySign |
boolean |
<optional> |
If truthy, only the sign of the answer is significant. |
Returns:
The signed distance.
- Type
- number
(static) ensureFunction(f) → {function}
- Description:
Return a function. If the supplied object is a function, return it. Otherwise, return a function that returns the argument.
- Source:
Parameters:
Name | Type | Description |
---|---|---|
f |
object | An object that might be a function. |
Returns:
A function. Either f
or a function that returns
f
.
- Type
- function
(static) escapeUnicodeHTML(text) → {string}
- Description:
Escape any character in a string that has a code point >= 127.
- Source:
Parameters:
Name | Type | Description |
---|---|---|
text |
string | The string to escape. |
Returns:
The escaped string.
- Type
- string
(static) getGeomBuffer(geom, srcName, len, allowLargeropt, allocateLargeropt) → {Float32Array}
- Description:
Get a buffer for a vgl geometry source. If a buffer already exists and is the correct size, return it. Otherwise, allocate a new buffer; any data in an old buffer is discarded.
- Source:
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
geom |
geo.vgl.geometryData | The geometry to reference and modify. |
||
srcName |
string | The name of the source. |
||
len |
number | The number of elements for the array. |
||
allowLarger |
number |
<optional> |
0.2
|
If the existing buffer is larger than
requested, don't reallocate it unless it exceeds the size of
|
allocateLarger |
number |
<optional> |
0.1
|
If reallocating an existing buffer,
allocate |
Returns:
A buffer for the named source.
- Type
- Float32Array
(static) getMinMaxValues(values, minopt, maxopt, limitopt) → {object}
- Description:
Given an array, return the minimum and maximum values within the array. If a numeric value is specified for one or the other, return that instead.
- Source:
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
values |
Array.<number> | An array of numeric values. |
||
min |
number |
<optional> |
If specified, use this instead of calculating the minimum. |
|
max |
number |
<optional> |
If specified, use this instead of calculating the maximum. |
|
limit |
boolean |
<optional> |
false
|
If truthy, if |
Returns:
An object with min
and max
, both numbers. If the
array is empty, undefined
may be returned for the min
and max
.
- Type
- object
(static) hasAction(actions, action, nameopt, owneropt) → (nullable) {geo.actionRecord}
- Description:
Check if an action is in the actions list. An action matches if the
action
,name
, andowner
match. Anull
orundefined
value will match all actions. If using ageo.actionRecord
object, this is the same as passing (action.action
,action.name
,action.owner
).
- Source:
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
actions |
Array.<geo.actionRecord> | An array of actions to search. |
|
action |
geo.actionRecord | string | Either an action object or the name of an action. |
|
name |
string |
<optional> |
Optional name associated with the action. |
owner |
string |
<optional> |
Optional owner associated with the action. |
Returns:
The first matching action or null
.
- Type
- geo.actionRecord
(static) htmlToImage(elem, parentsopt) → {jQuery.Deferred}
- Description:
Convert an html element to an image. This attempts to localize any images within the element. If there are other external references, the image may not work due to security considerations.
- Source:
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
elem |
jQuery.selector | Either a jquery selector or an HTML element. This may contain multiple elements. The direct parent and grandparent of the element are used for class information. |
|
parents |
number |
<optional> |
Number of layers up to travel to get class information. |
Returns:
A jquery deferred object which receives an HTML Image element when resolved.
- Type
- jQuery.Deferred
(static) htmlToImageSupported() → {boolean|jQuery.Deferred}
- Description:
Check if the current browser supports converting html to an image via an svg foreignObject and canvas. If this has not been checked before, it returns a Deferred that resolves to a boolean (never rejects). If the check has been done before, it returns a boolean.
- Source:
Returns:
- Type
- boolean | jQuery.Deferred
(static) isFunction(f) → {boolean}
- Description:
Test if an object is a function.
- Source:
Parameters:
Name | Type | Description |
---|---|---|
f |
object | An object that might be a function. |
Returns:
true
if the object is a function.
- Type
- boolean
(static) isObject(value) → {boolean}
- Description:
Test if an item is an object. This uses typeof not instanceof, since instanceof will return false for some things that we expect to be objects.
- Source:
Parameters:
Name | Type | Description |
---|---|---|
value |
* | The item to test. |
Returns:
True if the tested item is an object.
- Type
- boolean
(static) isReadyImage(img, allowFailedImageopt) → {boolean}
- Description:
Check if an object an HTML Image element that is fully loaded.
- Source:
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
img |
object | An object that might be an HTML Image element. |
|
allowFailedImage |
boolean |
<optional> |
If |
Returns:
true
if this is an image that is ready.
- Type
- boolean
(static) isReadyVideo(vid, allowFailedVideoopt) → {boolean}
- Description:
Check if an object an HTMLVideoElement element that is loaded.
- Source:
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
vid |
object | An object that might be an HTMLVideoElement. |
|
allowFailedVideo |
boolean |
<optional> |
If |
Returns:
true
if this is a video that is ready.
- Type
- boolean
(static) mat3AsArray() → {array}
- Description:
Create a
mat3
that is always an array. This should only be used if it will not be used in a WebGL context. Plain arrays usually use 64-bit float values, whereasmat3
defaults to 32-bit floats.
- Source:
Returns:
Identity mat3
compatible array.
- Type
- array
(static) mat4AsArray() → {array}
- Description:
Create a
mat4
that is always an array. This should only be used if it will not be used in a WebGL context. Plain arrays usually use 64-bit float values, whereasmat4
defaults to 32-bit floats.
- Source:
Returns:
Identity mat4
compatible array.
- Type
- array
(static) mockWebglRenderer(supportedopt)
- Description:
Replace webgl.renderer with a mocked version for testing in a non-webGL state. Use restoreWebglRenderer to unmock. Call vgl.mockCounts() to get the number of times different webGL functions have been called.
- Source:
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
supported |
boolean |
<optional> |
true
|
If false, then the webgl renderer will indicate that this is an unsupported browser environment. |
(static) normalizeCoordinates(p) → {geo.geoPosition}
- Description:
Normalize a coordinate object into
geo.geoPosition
form. The input can be a 2 or 3 element array or an object with a variety of properties.
- Source:
Parameters:
Name | Type | Description |
---|---|---|
p |
object | array | The point to convert. |
Returns:
The point as an object with x
, y
, and z
properties.
- Type
- geo.geoPosition
(static) pixelCoordinateParams(nodenullable, width, height, tileWidthopt, tileHeightopt) → {object}
- Description:
Return recommended defaults for map parameters and osm or tile layer parameters where the expected intent is to use the map in pixel coordinates (upper left is (0, 0), lower right is (
width
,height
).
- Source:
Example
var results = pixelCoordinateParams('#map', 10000, 9000);
var map = geo.map(Object.assign(results.map, {clampZoom: false}));
map.createLayer('osm', results.layer);
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
node |
string |
<nullable> |
DOM selector for the map container. |
width |
number | Width of the whole map contents in pixels. |
|
height |
number | Height of the whole map contents in pixels. |
|
tileWidth |
number |
<optional> |
If an osm or tile layer is going to be used, the width of a tile. |
tileHeight |
number |
<optional> |
If an osm or tile layer is going to be used, the height of a tile. |
Returns:
An object with map
and layer
properties. map
is
an object that can be passed to geo.map
, and layer
is an
object that can be passed to map.createLayer
.
- Type
- object
(static) pointInPolygon(point, outer, inneropt, rangeopt) → {boolean}
- Description:
Check if a point is inside of a polygon. The point and polygon must be in the same coordinate system. A point exactly on the edge is not considered inside.
- Source:
Parameters:
Name | Type | Attributes | Description | |||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
point |
geo.point2D | The test point. |
||||||||||
outer |
Array.<geo.point2D> | geo.polygonObject | The outer boundary of the polygon or a polygon object that has both the inner and outer boundaries. |
||||||||||
inner |
Array.<Array.<geo.point2D>> |
<optional> |
A list of inner boundaries (holes). |
|||||||||
range |
object |
<optional> |
If specified, this is the extent of the outer polygon and is used for early detection. Properties
|
Returns:
true
if the point is inside or on the border of the
polygon.
- Type
- boolean
(static) pointToTriangleBasis2d(point, vert0, vert1, vert2) → {geo.point2D}
- Description:
Return a point in the basis of the triangle. If the point is located on a vertex of the triangle, it will be at
vert0
: (0, 0),vert1
: (1, 0),vert2
: (0, 1). If it is within the triangle, its coordinates will be 0 <= x <= 1, 0 <= y <= 1, x + y <= 1. The point and vertices must be in the same coordinate system.
- Source:
Parameters:
Name | Type | Description |
---|---|---|
point |
geo.point2D | The point to convert. |
vert0 |
geo.point2D | Vertex 0 of the triangle. |
vert1 |
geo.point2D | Vertex 1 (x direction) of the triangle. |
vert2 |
geo.point2D | Vertex 2 (y direction) of the triangle. |
Returns:
The point in the triangle basis, or undefined
if the triangle is degenerate.
- Type
- geo.point2D
(static) randomString(nopt) → {string}
- Description:
Return a random string of length n || 8. The string consists of mixed-case ASCII alphanumerics.
- Source:
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
n |
number |
<optional> |
8
|
The length of the string to return. |
Returns:
A string of random characters.
- Type
- string
(static) range(start, end, stepopt) → {Array.<number>}
- Description:
Create an integer array contains elements from one integer to another integer.
- Source:
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
start |
number | The start integer. |
||
end |
number | The end integer. |
||
step |
number |
<optional> |
1
|
The step. |
Returns:
An array of integers.
- Type
- Array.<number>
(static) rdpLineSimplify(pts, tolerance, closedopt, noCrossLinesopt, nullable) → {Array.<geo.geoPosition>}
- Description:
Remove vertices from a chain of 2d line segments so that it is simpler but is close to the original overall shape within some tolerance limit. This is the Ramer–Douglas–Peucker algorithm. The first and last points will always remain the same for open lines. For closed lines (polygons), this picks an point that likely to be significant and then reduces it, possibly returning a single point.
- Source:
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
pts |
Array.<geo.geoPosition> | A list of points forming the line or polygon. |
|
tolerance |
number | The maximum variation allowed. A value of zero will only remove perfectly collinear points. |
|
closed |
boolean |
<optional> |
If true, this is a polygon rather than an open line. In this case, it is possible to get back a single point. |
noCrossLines |
Array.<Array.<geo.geoPosition>> |
<optional> <nullable> |
A falsy value to allow
the resultant line to cross itself, an empty array ( |
Returns:
The new point set.
- Type
- Array.<geo.geoPosition>
(static) removeAction(actions, action, nameopt, owneropt) → {number}
- Description:
Remove all matching actions. Actions are matched as with
hasAction
.
- Source:
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
actions |
Array.<geo.actionRecord> | An array of actions to adjust as needed. |
|
action |
geo.actionRecord | string | Either an action object or the name of an action. |
|
name |
string |
<optional> |
Optional name associated with the action. |
owner |
string |
<optional> |
Optional owner associated with the action. |
Returns:
The number of actions that were removed.
- Type
- number
(static) restoreWebglRenderer()
- Description:
Unmock the vgl renderer.
- Source:
(static) segmentCrossesLineList2d(pt1, pt2, lineList) → {boolean}
- Description:
Check if a line segment crosses any segment from a list of lines. The segment is considered crossing it it touches a line segment, unless that line segment shares a vertex with the segment.
- Source:
Parameters:
Name | Type | Description |
---|---|---|
pt1 |
geo.geoPosition | One end of the line segment. |
pt2 |
geo.geoPosition | The other end of the line segment. |
lineList |
Array.<Array.<geo.geoPosition>> | A list of open lines. Each line is a list of vertices. The line segment is checked against each segment of each line in this list. |
Returns:
True if the segment crosses any line segment.
- Type
- boolean
(static) throttle(delay, no_trailingopt, callbackopt, accumulatoropt, debounce_modeopt) → {function}
- Description:
Throttle execution of a function. Especially useful for rate limiting execution of handlers on events like resize and scroll. If you want to rate-limit execution of a function to a single time see
geo.util.debounce
.In this visualization, | is a throttled-function call and X is the actual callback execution:
Throttled with `no_trailing` specified as false or unspecified: ||||||||||||||||||||||||| (pause) ||||||||||||||||||||||||| X X X X X X X X X X X X Throttled with `no_trailing` specified as true: ||||||||||||||||||||||||| (pause) ||||||||||||||||||||||||| X X X X X X X X X X
This is also used to handle debouncing a function.
- Source:
Example
var throttled = geo.util.throttle( delay, [ no_trailing, ] callback );
$('selector').bind( 'someevent', throttled );
$('selector').unbind( 'someevent', throttled );
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
delay |
number | A zero-or-greater delay in milliseconds. For event callbacks, values around 100 or 250 (or even higher) are most useful. |
||
no_trailing |
boolean |
<optional> |
false
|
If no_trailing is
true, callback will only execute every |
callback |
function |
<optional> |
A function to be executed after |
|
accumulator |
function |
<optional> |
A function to be executed (synchronously) during each call to the wrapped function. Typically, this this method is used to accumulate values that the callback uses when it finally executes. |
|
debounce_mode |
boolean |
<optional> |
See the |
Returns:
The throttled version of callback
.
- Type
- function
(static) timeFunctionStart(name, reset)
- Description:
Note the start time of a function (or any other section of code). This should be paired with
timeFunctionStop
, which will collect statistics on the amount of time spent in a function.
- Source:
Parameters:
Name | Type | Description |
---|---|---|
name |
string | Name to use for tracking the timing. |
reset |
boolean | If |
(static) timeFunctionStop(name)
- Description:
Note the stop time of a function (or any other section of code). This should be paired with
timeFunctionStart
.
- Source:
Parameters:
Name | Type | Description |
---|---|---|
name |
string | Name to use for tracking the timing. |
(static) timeReport(nameopt) → {object}
- Description:
Report on one or all of the tracked timings.
- Source:
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
name |
string |
<optional> |
A name to report on, or |
Returns:
An object with timing information, or an object with properties for all tracked timings, each of which contains timing information.
- Type
- object
(static) timeRequestAnimationFrame(stopopt, resetopt, thresholdopt, keepopt)
- Description:
Start or stop tracking the time spent in
requestAnimationFrame
. If tracked, the results can be fetched viatimeFunctionReport('requestAnimationFrame')
.
- Source:
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
stop |
boolean |
<optional> |
Falsy to start tracking, truthy to start tracking. |
|
reset |
boolean |
<optional> |
If truthy, reset the statistics. |
|
threshold |
number |
<optional> |
15
|
If present, set the threshold in milliseconds used in tracking slow callbacks. |
keep |
number |
<optional> |
200
|
If present, set the number of recent frame times to track. |
(static) triangleTwiceSignedArea2d(pt1, pt2, pt3) → {number}
- Description:
Get twice the signed area of a 2d triangle.
- Source:
Parameters:
Name | Type | Description |
---|---|---|
pt1 |
geo.geoPosition | A vertex. |
pt2 |
geo.geoPosition | A vertex. |
pt3 |
geo.geoPosition | A vertex. |
Returns:
Twice the signed area.
- Type
- number
(static) vec3AsArray() → {array}
- Description:
Create a
vec3
that is always an array. This should only be used if it will not be used in a WebGL context. Plain arrays usually use 64-bit float values, whereasvec3
defaults to 32-bit floats.
- Source:
Returns:
Zeroed-out vec3 compatible array.
- Type
- array
(static) wrapAngle(value) → {number}
- Description:
Given a value in radians, return a value wrapped to the range [-PI, PI).
- Source:
Parameters:
Name | Type | Description |
---|---|---|
value |
number | A value in radians. |
Returns:
The wrapped value.
- Type
- number
Type Definitions
cssColorConversionRecord
- Source:
Properties:
Name | Type | Description |
---|---|---|
name |
string | The name of the color conversion. |
regex |
RegExp | A regex that, if it matches the color string, will cause the process function to be invoked. |
process |
function | A function that takes ( |
Type:
- object