UNPKG

kits-core

Version:
86 lines (78 loc) 2.16 kB
'use strict'; Object.defineProperty(exports, "__esModule", { value: true }); /** * * @param ref */ var scrollToTopByRef = exports.scrollToTopByRef = function scrollToTopByRef(ref) { ref && ref.current.scrollIntoView({ x: 0, behavior: 'smooth', top: ref && ref.current && ref.current.offsetTop }); }; /** * * @param ref */ var scrollToBottomByRef = exports.scrollToBottomByRef = function scrollToBottomByRef(ref) { ref && ref.current.scrollIntoView({ x: 0, behavior: 'smooth', top: ref && ref.current && ref.current.offsetBottom }); }; /** * * @param ref * @param x * @param y * @param bottomRefs * @returns {boolean} */ var scrollCheckLoadMore = exports.scrollCheckLoadMore = function scrollCheckLoadMore(ref, x, y, bottomRefs) { var scrollTop = ref && ref.current && ref.current.scrollTop; var clientHeight = ref && ref.current && ref.current.clientHeight; var scrollHeight = ref && ref.current && ref.current.scrollHeight; if (scrollTop + clientHeight === scrollHeight) { console.log('---------------------------------------------Load more---------------------------------------------'); return true; } }; /** * * @param value */ var copyToClipboard = exports.copyToClipboard = function copyToClipboard(value) { var el = document.createElement('textarea'); el.value = value; document.body.appendChild(el); el.select(); document.execCommand('copy'); document.body.removeChild(el); }; /** * * @param value */ var copyToClipboardLargeData = exports.copyToClipboardLargeData = function copyToClipboardLargeData(value) { var contentToCopy = void 0; function copyDataToClipboard(e) { e.preventDefault(); // default behaviour is to copy any selected text e.clipboardData.setData('text/plain', contentToCopy); } function copy(content) { contentToCopy = content; document.addEventListener('copy', copyDataToClipboard); try { document.execCommand('copy'); } catch (exception) { console.error('Copy to clipboard failed'); } finally { document.removeEventListener('copy', copyDataToClipboard); } } copy(value); };