Namespace: utils

PSV.utils

Classes

Animation

Interpolation helper for animations

Dynamic

Represents a variable that can dynamically change with time (using requestAnimationFrame)

MultiDynamic

Wrapper for multiple PSV.utils.Dynamic evolving together

Slider

Helper to make sliders elements

Methods

PSV.utils.addClasses (element, className) static

Adds one or several CSS classes to an element

Name Type Description
element HTMLElement
className string

PSV.utils.applyEulerInverse (vector, euler) static

Applies the inverse of Euler angles to a vector

Name Type Description
vector external:THREE.Vector3
euler external:THREE.Euler

PSV.utils.cleanPosition (value, options)Array.<string> static

Parse a CSS-like position into an array of position keywords among top, bottom, left, right and center

Name Type Description
value string | Array.<string>
options object optional
Name Type Default Description
allowCenter boolean true optional

allow "center center"

cssOrder boolean true optional

force CSS order (y axis then x axis)

Returns:
Type Description
Array.<string>

PSV.utils.clone (src)Object static

Deeply clones an object

Name Type Description
src Object
Returns:
Type Description
Object

PSV.utils.createTexture (img)external:THREE.Texture static

Creates a THREE texture from an image

Name Type Description
img HTMLImageElement | HTMLCanvasElement
Returns:
Type Description
external:THREE.Texture

PSV.utils.dasherize (str)string static

Transforms a string to dash-case https://github.com/shahata/dasherize

Name Type Description
str string
Returns:
Type Description
string

PSV.utils.deepmerge (target, src)Object static

Merges the enumerable attributes of two objects

Replaces arrays and alters the target object.

Name Type Description
target Object
src Object
Returns:
Type Description
Object target

PSV.utils.distance (p1, p2)number static

Computes the distance between two points

Name Type Description
p1 PSV.Point
p2 PSV.Point
Returns:
Type Description
number

PSV.utils.each (object, callback) static

Loops over enumerable properties of an object

Name Type Description
object Object
callback function

PSV.utils.exitFullscreen () static

Exits fullscreen mode

PSV.utils.firstNonNull (values)* static

Returns the first non null non undefined parameter

Name Type Description
values *
Returns:
Type Description
*

PSV.utils.getAbortError ()Error static

Builds an Error with name 'AbortError'

Returns:
Type Description
Error

PSV.utils.getAngle (position1, position2)number static

Computes the angle between the current position and a target position

Name Type Description
position1 PSV.Position
position2 PSV.Position
Returns:
Type Description
number

PSV.utils.getClosest (el, selector)HTMLElement static

Gets the closest parent (can by itself)

Name Type Description
el HTMLElement | SVGElement
selector string
Returns:
Type Description
HTMLElement

PSV.utils.getPosition (el)Object static

Gets the position of an element in the viewer without reflow

Will gives the same result as getBoundingClientRect() as soon as there are no CSS transforms

Name Type Description
el HTMLElement
Returns:
Type Description
Object

PSV.utils.getShortestArc (from, to)number static

Compute the shortest offset between two longitudes

Name Type Description
from number
to number
Returns:
Type Description
number

PSV.utils.getStyle (elt, prop)* static

Gets an element style

Name Type Description
elt HTMLElement
prop string
Returns:
Type Description
*

PSV.utils.getXMPValue (data, attr) static

Returns the value of a given attribute in the panorama metadata

Name Type Description
data string
attr string
Returns:
(number)

PSV.utils.greatArcDistance (p1, p2)number static

Returns the distance between two points on a sphere of radius one http://www.movable-type.co.uk/scripts/latlong.html

Name Type Description
p1 Array.<number>
p2 Array.<number>
Returns:
Type Description
number

PSV.utils.hasParent (el, parent)boolean static

Searches if an element has a particular parent at any level including itself

Name Type Description
el HTMLElement
parent HTMLElement
Returns:
Type Description
boolean

PSV.utils.isAbortError (err)boolean static

Tests if an Error has name 'AbortError'

Name Type Description
err Error
Returns:
Type Description
boolean

PSV.utils.isEmpty (obj)boolean static

Name Type Description
obj object
Returns:
Type Description
boolean

PSV.utils.isExtendedPosition (object)boolean static

Checks if an object is a {PSV.ExtendedPosition}, ie has x/y or longitude/latitude

Name Type Description
object object
Returns:
Type Description
boolean

PSV.utils.isFullscreenEnabled (elt)boolean static

Detects if fullscreen is enabled

Name Type Description
elt HTMLElement
Returns:
Type Description
boolean

PSV.utils.isNil (val)boolean static

Returns if a valu is null or undefined

Name Type Description
val *
Returns:
Type Description
boolean

PSV.utils.isPlainObject (obj)boolean static

Test if an object is a plain object

Test if an object is a plain object, i.e. is constructed by the built-in Object constructor and inherits directly from Object.prototype or null. Some built-in objects pass the test, e.g. Math which is a plain object and some host or exotic objects may pass also. http://stackoverflow.com/a/5878101/1207670

Name Type Description
obj *
Returns:
Type Description
boolean

PSV.utils.logWarn (message) static

Displays a warning in the console

Name Type Description
message string

PSV.utils.normalizeWheel (event)Object static

Normalize mousewheel values accross browsers

Name Type Description
event WheelEvent
Returns:
Type Description
Object

PSV.utils.parseAngle (angle, zeroCenter, halfCircle)number static

Parses an angle value in radians or degrees and returns a normalized value in radians

Name Type Default Description
angle string | number

eg: 3.14, 3.14rad, 180deg

zeroCenter boolean false optional

normalize between -Pi - Pi instead of 0 - 2*Pi

halfCircle boolean zeroCenter optional

normalize between -Pi/2 - Pi/2 instead of -Pi - Pi

Throws:

when the angle cannot be parsed

Type
PSV.PSVError
Returns:
Type Description
number

PSV.utils.parsePosition (value)PSV.Point static

Translate CSS values like "top center" or "10% 50%" as top and left positions

The implementation is as close as possible to the "background-position" specification https://developer.mozilla.org/en-US/docs/Web/CSS/background-position

Name Type Description
value string | PSV.Point
Returns:
Type Description
PSV.Point

PSV.utils.parseSpeed (speed)number static

Parses an speed

Name Type Description
speed string | number

The speed, in radians/degrees/revolutions per second/minute

Throws:

when the speed cannot be parsed

Type
PSV.PSVError
Returns:
Type Description
number radians per second

PSV.utils.pluginInterop () packagestatic

Returns the plugin constructor from the imported object For retrocompatibility with previous default exports

PSV.utils.removeClasses (element, className) static

Removes one or several CSS classes to an element

Name Type Description
element HTMLElement
className string

PSV.utils.requestFullscreen (elt) static

Enters fullscreen mode

Name Type Description
elt HTMLElement

PSV.utils.sum (array)number static

Computes the sum of an array

Name Type Description
array Array.<number>
Returns:
Type Description
number

PSV.utils.throttle (func, wait)function static

Returns a function, that, when invoked, will only be triggered at most once during a given window of time.

Name Type Description
func function
wait number
Returns:
Type Description
function

PSV.utils.toggleClass (element, className, active) static

Toggles a CSS class

Name Type Description
element HTMLElement | SVGElement
className string
active boolean optional

forced state