Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.
 
 
 
 

103 строки
3.7 KiB

  1. "use strict";
  2. var noop = function() {};
  3. function applyPrefixToName(prefix, name) {
  4. return name ? "-" === name[0] ? prefix + name : prefix + "__" + name : prefix;
  5. }
  6. function classNames(prefix, state, className) {
  7. var arr = [ className ];
  8. if (state && prefix) for (var key in state) state.hasOwnProperty(key) && state[key] && arr.push("" + applyPrefixToName(prefix, key));
  9. return arr.filter((function(i) {
  10. return i;
  11. })).map((function(i) {
  12. return String(i).trim();
  13. })).join(" ");
  14. }
  15. var cleanValue = function(value) {
  16. return Array.isArray(value) ? value.filter(Boolean) : "object" == typeof value && null !== value ? [ value ] : [];
  17. };
  18. function handleInputChange(inputValue, actionMeta, onInputChange) {
  19. if (onInputChange) {
  20. var newValue = onInputChange(inputValue, actionMeta);
  21. if ("string" == typeof newValue) return newValue;
  22. }
  23. return inputValue;
  24. }
  25. function isDocumentElement(el) {
  26. return [ document.documentElement, document.body, window ].indexOf(el) > -1;
  27. }
  28. function getScrollTop(el) {
  29. return isDocumentElement(el) ? window.pageYOffset : el.scrollTop;
  30. }
  31. function scrollTo(el, top) {
  32. isDocumentElement(el) ? window.scrollTo(0, top) : el.scrollTop = top;
  33. }
  34. function getScrollParent(element) {
  35. var style = getComputedStyle(element), excludeStaticParent = "absolute" === style.position, overflowRx = /(auto|scroll)/, docEl = document.documentElement;
  36. if ("fixed" === style.position) return docEl;
  37. for (var parent = element; parent = parent.parentElement; ) if (style = getComputedStyle(parent),
  38. (!excludeStaticParent || "static" !== style.position) && overflowRx.test(style.overflow + style.overflowY + style.overflowX)) return parent;
  39. return docEl;
  40. }
  41. function easeOutCubic(t, b, c, d) {
  42. return c * ((t = t / d - 1) * t * t + 1) + b;
  43. }
  44. function animatedScrollTo(element, to, duration, callback) {
  45. void 0 === duration && (duration = 200), void 0 === callback && (callback = noop);
  46. var start = getScrollTop(element), change = to - start, increment = 10, currentTime = 0;
  47. !function animateScroll() {
  48. var val = easeOutCubic(currentTime += increment, start, change, duration);
  49. scrollTo(element, val), currentTime < duration ? window.requestAnimationFrame(animateScroll) : callback(element);
  50. }();
  51. }
  52. function scrollIntoView(menuEl, focusedEl) {
  53. var menuRect = menuEl.getBoundingClientRect(), focusedRect = focusedEl.getBoundingClientRect(), overScroll = focusedEl.offsetHeight / 3;
  54. focusedRect.bottom + overScroll > menuRect.bottom ? scrollTo(menuEl, Math.min(focusedEl.offsetTop + focusedEl.clientHeight - menuEl.offsetHeight + overScroll, menuEl.scrollHeight)) : focusedRect.top - overScroll < menuRect.top && scrollTo(menuEl, Math.max(focusedEl.offsetTop - overScroll, 0));
  55. }
  56. function getBoundingClientObj(element) {
  57. var rect = element.getBoundingClientRect();
  58. return {
  59. bottom: rect.bottom,
  60. height: rect.height,
  61. left: rect.left,
  62. right: rect.right,
  63. top: rect.top,
  64. width: rect.width
  65. };
  66. }
  67. function isTouchCapable() {
  68. try {
  69. return document.createEvent("TouchEvent"), !0;
  70. } catch (e) {
  71. return !1;
  72. }
  73. }
  74. function isMobileDevice() {
  75. try {
  76. return /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent);
  77. } catch (e) {
  78. return !1;
  79. }
  80. }
  81. exports.animatedScrollTo = animatedScrollTo, exports.classNames = classNames, exports.cleanValue = cleanValue,
  82. exports.getBoundingClientObj = getBoundingClientObj, exports.getScrollParent = getScrollParent,
  83. exports.getScrollTop = getScrollTop, exports.handleInputChange = handleInputChange,
  84. exports.isDocumentElement = isDocumentElement, exports.isMobileDevice = isMobileDevice,
  85. exports.isTouchCapable = isTouchCapable, exports.noop = noop, exports.scrollIntoView = scrollIntoView,
  86. exports.scrollTo = scrollTo;