cables_dev/cables/src/core/cgl/cgl_utils.js
- /** @namespace CGL */
-
- /**
- * multiply to get radians from degree, e.g. `360 * CGL.DEG2RAD`
- * @const {Number}
- * @memberof CGL
- * @static
- */
- export const DEG2RAD = Math.PI / 180.0;
-
- /**
- * to get degrees from radians, e.g. `3.14 * CGL.RAD2DEG`
- * @const {number}
- * @memberof CGL
- */
- export const RAD2DEG = 180.0 / Math.PI;
-
- export const onLoadingAssetsFinished = null; // deprecated / remove later
-
- /**
- * get normalized mouse wheel delta (including browser specific adjustment)
- * @function getWheelDelta
- * @static
- * @memberof CGL
- * @param {MouseEvent} event
- * @return {Number} normalized delta
- */
- export const isWindows = window.navigator.userAgent.contains("Windows");
- const getWheelDelta_ = function (event)
- {
- let normalized;
- if (event.wheelDelta)
- {
- // chrome
- normalized = (event.wheelDelta % 120) - 0 == -0 ? event.wheelDelta / 120 : event.wheelDelta / 30;
- normalized *= -1.5;
- if (isWindows) normalized *= 2;
- }
- else
- {
- // firefox
- let d = event.deltaY;
- if (event.shiftKey) d = event.deltaX;
- const rawAmmount = d || event.detail;
- normalized = -(rawAmmount % 3 ? rawAmmount * 10 : rawAmmount / 3);
- normalized *= -3;
- }
-
- if (normalized > 20) normalized = 20;
- if (normalized < -20) normalized = -20;
-
- return normalized;
- };
-
- export const getWheelSpeed = getWheelDelta_;
- export const getWheelDelta = getWheelDelta_;
-
- // from https://github.com/lodash/lodash/blob/master/escape.js
-
- const htmlEscapes = {
- "&": "&",
- "<": "<",
- ">": ">",
- "\"": """,
- "'": "'",
- };
-
- /** Used to match HTML entities and HTML characters. */
- const reUnescapedHtml = /[&<>"']/g;
- const reHasUnescapedHtml = RegExp(reUnescapedHtml.source);
-
- /* eslint-disable */
- export const escapeHTML = function(string)
- {
- return string && reHasUnescapedHtml.test(string) ?
- string.replace(reUnescapedHtml, function(chr) { return htmlEscapes[chr]; })
- : string || "";
- }
- /* eslint-enable */