initial structure for components rewrite
This commit is contained in:
1 parent
944afe4a3e
commit
c391c007ff
284 files changed
+68087
-17215
No files matched your search
@@ -1,41 +0,0 @@
|
||||
/**
|
||||
* Get the vertical and horizontal scrollbar sizes
|
||||
* Got from https://stackoverflow.com/questions/986937/how-can-i-get-the-browsers-scrollbar-sizes
|
||||
*
|
||||
* @returns {Array} Array containing the scrollbar horizontal and vertical sizes
|
||||
*/
|
||||
export default function getScrollbarSize() {
|
||||
const inner = document.createElement('p');
|
||||
inner.style.width = '100%';
|
||||
inner.style.height = '100%';
|
||||
|
||||
const outer = document.createElement('div');
|
||||
outer.style.position = 'absolute';
|
||||
outer.style.top = '0px';
|
||||
outer.style.left = '0px';
|
||||
outer.style.visibility = 'hidden';
|
||||
outer.style.width = '100px';
|
||||
outer.style.height = '100px';
|
||||
outer.style.overflow = 'hidden';
|
||||
outer.appendChild(inner);
|
||||
|
||||
document.body.appendChild(outer);
|
||||
|
||||
const w1 = inner.offsetWidth;
|
||||
const h1 = inner.offsetHeight;
|
||||
outer.style.overflow = 'scroll';
|
||||
let w2 = inner.offsetWidth;
|
||||
let h2 = inner.offsetHeight;
|
||||
|
||||
if (w1 === w2) {
|
||||
w2 = outer.clientWidth;
|
||||
}
|
||||
|
||||
if (h1 === h2) {
|
||||
h2 = outer.clientHeight;
|
||||
}
|
||||
|
||||
document.body.removeChild(outer);
|
||||
|
||||
return [w1 - w2, h1 - h2];
|
||||
}
|
||||
@@ -1,57 +0,0 @@
|
||||
// https://github.com/swederik/dragula/blob/ccc15d75186f5168e7abadbe3077cf12dab09f8b/styleProperty.js
|
||||
|
||||
const browserProps = {};
|
||||
|
||||
function eachVendor(prop, fn) {
|
||||
const prefixes = ['Webkit', 'Moz', 'ms', 'O'];
|
||||
fn(prop);
|
||||
for (let i = 0; i < prefixes.length; i++) {
|
||||
fn(prefixes[i] + prop.charAt(0).toUpperCase() + prop.slice(1));
|
||||
}
|
||||
}
|
||||
|
||||
function check(property, testValue) {
|
||||
const sandbox = document.createElement('iframe');
|
||||
const element = document.createElement('p');
|
||||
|
||||
document.body.appendChild(sandbox);
|
||||
sandbox.contentDocument.body.appendChild(element);
|
||||
const support = set(element, property, testValue);
|
||||
|
||||
// We have to do this because remove() is not supported by IE11 and below
|
||||
sandbox.parentElement.removeChild(sandbox);
|
||||
return support;
|
||||
}
|
||||
|
||||
function checkComputed(el, prop) {
|
||||
const computed = window.getComputedStyle(el).getPropertyValue(prop);
|
||||
return computed !== void 0 && computed.length > 0 && computed !== 'none';
|
||||
}
|
||||
|
||||
function set(el, prop, value) {
|
||||
let match = false;
|
||||
|
||||
if (browserProps[prop] === void 0) {
|
||||
eachVendor(prop, function(vendorProp) {
|
||||
if (el.style[vendorProp] !== void 0 && match === false) {
|
||||
el.style[vendorProp] = value;
|
||||
if (checkComputed(el, vendorProp)) {
|
||||
match = true;
|
||||
browserProps[prop] = vendorProp;
|
||||
}
|
||||
}
|
||||
});
|
||||
} else {
|
||||
el.style[browserProps[prop]] = value;
|
||||
return true;
|
||||
}
|
||||
|
||||
return match;
|
||||
}
|
||||
|
||||
const styleProperty = {
|
||||
check,
|
||||
set,
|
||||
};
|
||||
|
||||
export default styleProperty;
|
||||
@@ -1,26 +0,0 @@
|
||||
export default function throttled(delay, callback) {
|
||||
let isThrottled = false,
|
||||
args,
|
||||
context;
|
||||
|
||||
function wrapper() {
|
||||
if (isThrottled) {
|
||||
args = arguments;
|
||||
context = this;
|
||||
return;
|
||||
}
|
||||
|
||||
isThrottled = true;
|
||||
callback.apply(this, arguments);
|
||||
|
||||
setTimeout(() => {
|
||||
isThrottled = false;
|
||||
if (args) {
|
||||
wrapper.apply(context, args);
|
||||
args = context = null;
|
||||
}
|
||||
}, delay);
|
||||
}
|
||||
|
||||
return wrapper;
|
||||
}
|
||||
@@ -1,21 +0,0 @@
|
||||
import React from 'react';
|
||||
import { DndProvider } from "react-dnd";
|
||||
import HTML5Backend from 'react-dnd-html5-backend';
|
||||
import TouchBackend from 'react-dnd-touch-backend';
|
||||
|
||||
const isTouchDevice = !!('ontouchstart' in window || navigator.maxTouchPoints);
|
||||
|
||||
// See https://github.com/react-dnd/react-dnd/issues/186#issuecomment-335429067
|
||||
// https://github.com/react-dnd/react-dnd/issues/186#issuecomment-282789420
|
||||
//
|
||||
// http://react-dnd.github.io/react-dnd/docs/api/drag-drop-context
|
||||
export default function viewerbaseDragDropContext(DecoratedClass) {
|
||||
const backend = isTouchDevice ? TouchBackend : HTML5Backend;
|
||||
const opts = isTouchDevice ? { enableMouseEvents: true } : {};
|
||||
|
||||
return (props) => (
|
||||
<DndProvider backend={backend} opts={opts}>
|
||||
<DecoratedClass {...props}/>
|
||||
</DndProvider>
|
||||
);
|
||||
}
|
||||
Reference in new issue
Block a user