Namespace: utils

PSV.utils

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.bound (x, min, max)number static

Ensures that a number is in a given interval

Name Type Description
x number
min number
max number
Returns:
Type Description
number

PSV.utils.clone (src)Object static

Deeply clones an object

Name Type Description
src Object
Returns:
Type Description
Object

PSV.utils.dasherize (str)string static

Transforms a string to dash-casehttps://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.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.getEventKey (evt)string static

Returns the key name of a KeyboardEvent

Name Type Description
evt KeyboardEvent
Returns:
Type Description
string

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:
(string)

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

Returns the distance between two points on a sphere of radius one

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.intersect (array1, array2)Array.<T> static

Returns the intersection between two arrays

Name Type Description
array1 Array.<T>
array2 Array.<T>
Returns:
Type Description
Array.<T>

PSV.utils.isEmpty (obj)boolean static

Name Type Description
obj 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.isInteger (value)boolean static

Checks if a value is an integer

Name Type Description
value *
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 MouseWheelEvent
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 | object
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.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