mirror of
https://github.com/tenrok/OverlayScrollbars.git
synced 2026-05-28 14:14:07 +03:00
fix ie11
This commit is contained in:
+16
-6
@@ -70,8 +70,19 @@ function each(source, callback) {
|
||||
|
||||
return source;
|
||||
}
|
||||
const from = (arr) => {
|
||||
if (Array.from) {
|
||||
return Array.from(arr);
|
||||
}
|
||||
|
||||
const contents = (elm) => (elm ? Array.from(elm.childNodes) : []);
|
||||
const result = [];
|
||||
each(arr, (elm) => {
|
||||
result.push(elm);
|
||||
});
|
||||
return result;
|
||||
};
|
||||
|
||||
const contents = (elm) => (elm ? from(elm.childNodes) : []);
|
||||
|
||||
const before = (parentElm, preferredAnchor, insertedElms) => {
|
||||
if (insertedElms) {
|
||||
@@ -110,7 +121,7 @@ const appendChildren = (node, children) => {
|
||||
};
|
||||
const removeElements = (nodes) => {
|
||||
if (isArrayLike(nodes)) {
|
||||
each(Array.from(nodes), (e) => removeElements(e));
|
||||
each(from(nodes), (e) => removeElements(e));
|
||||
} else if (nodes) {
|
||||
const { parentNode } = nodes;
|
||||
|
||||
@@ -127,7 +138,6 @@ const createDOM = (html) => {
|
||||
return each(contents(createdDiv), (elm) => removeElements(elm));
|
||||
};
|
||||
|
||||
const zeroDomRect = new DOMRect();
|
||||
const zeroObj = {
|
||||
w: 0,
|
||||
h: 0,
|
||||
@@ -150,6 +160,7 @@ const clientSize = (elm) =>
|
||||
h: elm.clientHeight,
|
||||
}
|
||||
: zeroObj;
|
||||
const getBoundingClientRect = (elm) => elm.getBoundingClientRect();
|
||||
|
||||
const cssNumber = {
|
||||
animationiterationcount: 1,
|
||||
@@ -207,7 +218,7 @@ const zeroObj$1 = {
|
||||
y: 0,
|
||||
};
|
||||
const offset = (elm) => {
|
||||
const rect = elm ? elm.getBoundingClientRect() : 0;
|
||||
const rect = elm ? getBoundingClientRect(elm) : 0;
|
||||
return rect
|
||||
? {
|
||||
x: rect.left + window.pageYOffset,
|
||||
@@ -480,10 +491,9 @@ class Environment {
|
||||
}
|
||||
}
|
||||
|
||||
const env = new Environment();
|
||||
var index = () => {
|
||||
return [
|
||||
env,
|
||||
new Environment(),
|
||||
createDOM(
|
||||
'\
|
||||
<div class="os-host">\
|
||||
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
+18
-6
@@ -87,9 +87,20 @@
|
||||
|
||||
return source;
|
||||
}
|
||||
var from = function from(arr) {
|
||||
if (Array.from) {
|
||||
return Array.from(arr);
|
||||
}
|
||||
|
||||
var result = [];
|
||||
each(arr, function (elm) {
|
||||
result.push(elm);
|
||||
});
|
||||
return result;
|
||||
};
|
||||
|
||||
var contents = function contents(elm) {
|
||||
return elm ? Array.from(elm.childNodes) : [];
|
||||
return elm ? from(elm.childNodes) : [];
|
||||
};
|
||||
|
||||
var before = function before(parentElm, preferredAnchor, insertedElms) {
|
||||
@@ -129,7 +140,7 @@
|
||||
};
|
||||
var removeElements = function removeElements(nodes) {
|
||||
if (isArrayLike(nodes)) {
|
||||
each(Array.from(nodes), function (e) {
|
||||
each(from(nodes), function (e) {
|
||||
return removeElements(e);
|
||||
});
|
||||
} else if (nodes) {
|
||||
@@ -152,7 +163,6 @@
|
||||
});
|
||||
};
|
||||
|
||||
var zeroDomRect = new DOMRect();
|
||||
var zeroObj = {
|
||||
w: 0,
|
||||
h: 0,
|
||||
@@ -179,6 +189,9 @@
|
||||
}
|
||||
: zeroObj;
|
||||
};
|
||||
var getBoundingClientRect = function getBoundingClientRect(elm) {
|
||||
return elm.getBoundingClientRect();
|
||||
};
|
||||
|
||||
var cssNumber = {
|
||||
animationiterationcount: 1,
|
||||
@@ -242,7 +255,7 @@
|
||||
y: 0,
|
||||
};
|
||||
var offset = function offset(elm) {
|
||||
var rect = elm ? elm.getBoundingClientRect() : 0;
|
||||
var rect = elm ? getBoundingClientRect(elm) : 0;
|
||||
return rect
|
||||
? {
|
||||
x: rect.left + window.pageYOffset,
|
||||
@@ -526,10 +539,9 @@
|
||||
return Environment;
|
||||
})();
|
||||
|
||||
var env = new Environment();
|
||||
var index = function () {
|
||||
return [
|
||||
env,
|
||||
new Environment(),
|
||||
createDOM(
|
||||
'\
|
||||
<div class="os-host">\
|
||||
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -6,10 +6,10 @@ const abc = {
|
||||
b: 1,
|
||||
c: 1,
|
||||
};
|
||||
const env = new Environment();
|
||||
|
||||
export default () => {
|
||||
return [
|
||||
env,
|
||||
new Environment(),
|
||||
createDOM(
|
||||
'\
|
||||
<div class="os-host">\
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { isArrayLike } from 'support/utils/types';
|
||||
import { each } from 'support/utils/array';
|
||||
import { each, from } from 'support/utils/array';
|
||||
import { parent } from 'support/dom/traversal';
|
||||
|
||||
type NodeCollection = ArrayLike<Node> | Node | undefined | null;
|
||||
@@ -87,7 +87,7 @@ export const insertAfter = (node: Node | null, insertedNodes: NodeCollection): v
|
||||
*/
|
||||
export const removeElements = (nodes: NodeCollection): void => {
|
||||
if (isArrayLike(nodes)) {
|
||||
each(Array.from(nodes), (e) => removeElements(e));
|
||||
each(from(nodes), (e) => removeElements(e));
|
||||
} else if (nodes) {
|
||||
const { parentNode } = nodes;
|
||||
if (parentNode) {
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { XY, getBoundingClientRect } from 'support/dom';
|
||||
import { getBoundingClientRect } from 'support/dom/dimensions';
|
||||
import { XY } from 'support/dom';
|
||||
|
||||
const zeroObj: XY = {
|
||||
x: 0,
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { each } from 'support/utils/array';
|
||||
import { each, from } from 'support/utils/array';
|
||||
|
||||
const elementIsVisible = (elm: HTMLElement): boolean => !!(elm.offsetWidth || elm.offsetHeight || elm.getClientRects().length);
|
||||
|
||||
@@ -45,6 +45,6 @@ export const children = (elm: Element | null, selector?: string): ReadonlyArray<
|
||||
return childs;
|
||||
};
|
||||
|
||||
export const contents = (elm: Element | null): ReadonlyArray<ChildNode> => (elm ? Array.from<ChildNode>(elm.childNodes) : []);
|
||||
export const contents = (elm: Element | null): ReadonlyArray<ChildNode> => (elm ? from(elm.childNodes) : []);
|
||||
|
||||
export const parent = (elm: Node | null): Node | null => (elm ? elm.parentElement : null);
|
||||
|
||||
@@ -11,25 +11,25 @@ import { PlainObject } from 'typings';
|
||||
*/
|
||||
export function each<T>(
|
||||
array: Array<T> | ReadonlyArray<T>,
|
||||
callback: (value: T, indexOrKey: number, source: Array<T>) => boolean | void,
|
||||
callback: (value: T, indexOrKey: number, source: Array<T>) => boolean | void
|
||||
): Array<T> | ReadonlyArray<T>;
|
||||
export function each<T>(
|
||||
array: Array<T> | ReadonlyArray<T> | null,
|
||||
callback: (value: T, indexOrKey: number, source: Array<T>) => boolean | void,
|
||||
callback: (value: T, indexOrKey: number, source: Array<T>) => boolean | void
|
||||
): Array<T> | ReadonlyArray<T> | null;
|
||||
export function each<T>(
|
||||
arrayLikeObject: ArrayLike<T>,
|
||||
callback: (value: T, indexOrKey: number, source: ArrayLike<T>) => boolean | void,
|
||||
callback: (value: T, indexOrKey: number, source: ArrayLike<T>) => boolean | void
|
||||
): ArrayLike<T>;
|
||||
export function each<T>(
|
||||
arrayLikeObject: ArrayLike<T> | null,
|
||||
callback: (value: T, indexOrKey: number, source: ArrayLike<T>) => boolean | void,
|
||||
callback: (value: T, indexOrKey: number, source: ArrayLike<T>) => boolean | void
|
||||
): ArrayLike<T> | null;
|
||||
export function each(obj: PlainObject, callback: (value: any, indexOrKey: string, source: PlainObject) => boolean | void): PlainObject;
|
||||
export function each(obj: PlainObject | null, callback: (value: any, indexOrKey: string, source: PlainObject) => boolean | void): PlainObject | null;
|
||||
export function each<T>(
|
||||
source: ArrayLike<T> | PlainObject | null,
|
||||
callback: (value: T | any, indexOrKey: any, source: any) => boolean | void,
|
||||
callback: (value: T | any, indexOrKey: any, source: any) => boolean | void
|
||||
): Array<T> | ReadonlyArray<T> | ArrayLike<T> | PlainObject | null {
|
||||
if (isArrayLike(source)) {
|
||||
for (let i = 0; i < source.length; i++) {
|
||||
@@ -50,3 +50,14 @@ export function each<T>(
|
||||
* @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the search starts at index 0.
|
||||
*/
|
||||
export const indexOf = <T = any>(arr: Array<T>, item: T, fromIndex?: number): number => arr.indexOf(item, fromIndex);
|
||||
|
||||
export const from = <T = any>(arr: ArrayLike<T>) => {
|
||||
if (Array.from) {
|
||||
return Array.from(arr);
|
||||
}
|
||||
const result: Array<T> = [];
|
||||
each(arr, (elm) => {
|
||||
result.push(elm);
|
||||
});
|
||||
return result;
|
||||
};
|
||||
|
||||
@@ -2,4 +2,4 @@ import { WH } from 'support/dom';
|
||||
export declare const windowSize: () => WH;
|
||||
export declare const offsetSize: (elm: HTMLElement | null) => WH;
|
||||
export declare const clientSize: (elm: HTMLElement | null) => WH;
|
||||
export declare const getBoundingClientRect: (elm: HTMLElement | null) => DOMRect;
|
||||
export declare const getBoundingClientRect: (elm: HTMLElement) => DOMRect;
|
||||
|
||||
@@ -6,3 +6,4 @@ export declare function each<T>(arrayLikeObject: ArrayLike<T> | null, callback:
|
||||
export declare function each(obj: PlainObject, callback: (value: any, indexOrKey: string, source: PlainObject) => boolean | void): PlainObject;
|
||||
export declare function each(obj: PlainObject | null, callback: (value: any, indexOrKey: string, source: PlainObject) => boolean | void): PlainObject | null;
|
||||
export declare const indexOf: <T = any>(arr: T[], item: T, fromIndex?: number | undefined) => number;
|
||||
export declare const from: <T = any>(arr: ArrayLike<T>) => T[];
|
||||
|
||||
Reference in New Issue
Block a user