Skip to content

Commit

Permalink
fix: support iframe #932
Browse files Browse the repository at this point in the history
  • Loading branch information
daybrush committed May 31, 2023
1 parent 7b4cbad commit 15abedb
Show file tree
Hide file tree
Showing 11 changed files with 51 additions and 57 deletions.
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@
]
},
"resolutions": {
"@daybrush/utils": "^1.11.0",
"@daybrush/utils": "^1.12.1",
"@types/react": "^16.9.17",
"typescript": "^4.5.0 <4.6.0",
"@storybook/react": "^6.4.22",
Expand All @@ -112,14 +112,14 @@
"@scena/matrix": "^1.1.1",
"css-to-mat": "^1.0.3",
"framework-utils": "^1.1.0",
"gesto": "^1.18.0",
"gesto": "^1.18.1",
"overlap-area": "^1.1.0",
"croact-css-styled": "^1.1.8",
"react-css-styled": "^1.1.8",
"tslib": "^2.3.1"
},
"overrides": {
"@daybrush/utils": "^1.11.0",
"@daybrush/utils": "^1.12.1",
"@types/react": "^16.9.17",
"typescript": "^4.5.0 <4.6.0",
"@storybook/react": "^6.4.22",
Expand All @@ -136,7 +136,7 @@
"@scena/matrix": "^1.1.1",
"css-to-mat": "^1.0.3",
"framework-utils": "^1.1.0",
"gesto": "^1.18.0",
"gesto": "^1.18.1",
"overlap-area": "^1.1.0",
"croact-css-styled": "^1.1.8",
"react-css-styled": "^1.1.8",
Expand Down
4 changes: 2 additions & 2 deletions packages/croact-moveable/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@
"typescript": "^4.5.0 <4.6.0"
},
"dependencies": {
"@daybrush/utils": "^1.11.0",
"@daybrush/utils": "^1.12.1",
"@egjs/agent": "^2.2.1",
"@egjs/children-differ": "^1.0.1",
"@egjs/list-differ": "^1.0.0",
Expand All @@ -78,7 +78,7 @@
"croact-css-styled": "^1.1.8",
"css-to-mat": "^1.0.3",
"framework-utils": "^1.1.0",
"gesto": "^1.18.0",
"gesto": "^1.18.1",
"overlap-area": "^1.1.0",
"react-css-styled": "^1.1.8",
"react-moveable": "~0.50.7"
Expand Down
2 changes: 1 addition & 1 deletion packages/lit-moveable/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
"typescript": "^4.5.0 <4.6.0"
},
"dependencies": {
"@daybrush/utils": "^1.11.0",
"@daybrush/utils": "^1.12.1",
"framework-utils": "^1.1.0",
"moveable": "~0.47.9"
}
Expand Down
4 changes: 2 additions & 2 deletions packages/react-moveable/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@
"wait-on": "^7.0.1"
},
"dependencies": {
"@daybrush/utils": "^1.11.0",
"@daybrush/utils": "^1.12.1",
"@egjs/agent": "^2.2.1",
"@egjs/children-differ": "^1.0.1",
"@egjs/list-differ": "^1.0.0",
Expand All @@ -129,7 +129,7 @@
"@scena/matrix": "^1.1.1",
"css-to-mat": "^1.0.3",
"framework-utils": "^1.1.0",
"gesto": "^1.18.0",
"gesto": "^1.18.1",
"overlap-area": "^1.1.0",
"react-css-styled": "^1.1.8"
},
Expand Down
4 changes: 2 additions & 2 deletions packages/react-moveable/src/gesto/getAbleGesto.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Able, MoveableManagerInterface, MoveableGroupInterface } from "../types";
import { hasClass, IObject } from "@daybrush/utils";
import { getWindow, hasClass, IObject } from "@daybrush/utils";
import { convertDragDist, defaultSync } from "../utils";
import Gesto, { GestoOptions } from "gesto";
import BeforeRenderable from "../ables/BeforeRenderable";
Expand Down Expand Up @@ -262,7 +262,7 @@ export function getAbleGesto(
preventDefault,
preventRightClick: true,
preventWheelClick: true,
container: window,
container: getWindow(moveable.getControlBoxElement()),
pinchThreshold,
pinchOutside,
preventClickEventOnDrag: isTargetAbles ? preventClickEventOnDrag : false,
Expand Down
4 changes: 2 additions & 2 deletions packages/react-moveable/src/store/Store.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { find } from "@daybrush/utils";
import { find, getWindow } from "@daybrush/utils";
import { getClientRect } from "../utils";
import { MoveableClientRect } from "../types";
import { getMatrixStackInfo, MatrixStackInfo } from "../utils/getMatrixStackInfo";
Expand Down Expand Up @@ -65,7 +65,7 @@ export function getCachedStyle(element: Element): GetStyle {
let cache = cacheStyleMap?.get(element);

if (!cache) {
const nextStyle = window.getComputedStyle(element);
const nextStyle = getWindow(element).getComputedStyle(element);

if (!cacheStyleMap) {
return (property: string) => {
Expand Down
18 changes: 5 additions & 13 deletions packages/react-moveable/src/utils.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ import {
isUndefined, isObject, splitUnit,
IObject, hasClass, isArray, isString, getRad,
getShapeDirection, isFunction, convertUnitSize, between, getKeys, decamelize, isNumber,
getDocumentBody,
getDocumentElement,
getWindow,
} from "@daybrush/utils";
import {
multiply, invert,
Expand Down Expand Up @@ -133,7 +136,7 @@ export function getOffsetInfo(
getTargetStyle?: GetStyle,
) {

const documentElement = getDocumentElement(el) || getDocumentBody(el);
const documentElement = getDocumentElement(el!) || getDocumentBody(el!);
let hasSlot = false;
let target: HTMLElement | SVGElement | null | undefined;
let parentSlotElement: HTMLElement | null | undefined;
Expand Down Expand Up @@ -1111,7 +1114,7 @@ export function triggerEvent<EventName extends keyof Props, Props extends IObjec
}

export function getComputedStyle(el: Element, pseudoElt?: string | null) {
return window.getComputedStyle(el, pseudoElt);
return getWindow(el).getComputedStyle(el, pseudoElt);
}

export function filterAbles(
Expand Down Expand Up @@ -1698,14 +1701,3 @@ export function watchValue<T>(
store[property] = nextValue;
return nextValue;
}


export function getDocument(el: Node | null | undefined) {
return el?.ownerDocument || document;
}
export function getDocumentBody(el: Node | null | undefined) {
return getDocument(el).body;
}
export function getDocumentElement(el: Node | null | undefined) {
return getDocument(el).documentElement;
}
3 changes: 2 additions & 1 deletion packages/react-moveable/src/utils/calculateMatrixStack.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { createIdentityMatrix, convertDimension, multiply, createOriginMatrix, ignoreDimension } from "@scena/matrix";
import { getCachedMatrixContainerInfo } from "../store/Store";
import { convert3DMatrixes, getDocumentBody, getOffsetInfo, getSVGOffset, makeMatrixCSS } from "../utils";
import { convert3DMatrixes, getOffsetInfo, getSVGOffset, makeMatrixCSS } from "../utils";
import { getMatrixStackInfo } from "./getMatrixStackInfo";
import { getDocumentBody } from "@daybrush/utils";

export interface MoveableElementMatrixInfo {
hasZoom: boolean;
Expand Down
3 changes: 2 additions & 1 deletion packages/react-moveable/src/utils/getMatrixStackInfo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@ import {
getOffsetInfo, getElementTransform,
getTransformMatrix, getPositionFixedInfo,
convert3DMatrixes, getOffsetPosInfo,
getSVGMatrix, getBodyOffset, getAbsoluteMatrix, getDocumentElement, getDocumentBody,
getSVGMatrix, getBodyOffset, getAbsoluteMatrix,
} from "../utils";
import { getDocumentBody, getDocumentElement } from "@daybrush/utils";


export function getShadowRoot(parentElement: HTMLElement | SVGElement) {
Expand Down
2 changes: 1 addition & 1 deletion packages/snappable/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
"typescript": "^4.5.0 <4.6.0"
},
"dependencies": {
"@daybrush/utils": "^1.11.0",
"@daybrush/utils": "^1.12.1",
"overlap-area": "^1.1.0"
}
}
56 changes: 28 additions & 28 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2860,10 +2860,10 @@
sinon "^7.4.1"
source-map-support "^0.5.13"

"@daybrush/utils@^0.10.0", "@daybrush/utils@^0.10.1", "@daybrush/utils@^0.11.0", "@daybrush/utils@^0.5.2", "@daybrush/utils@^0.7.1", "@daybrush/utils@^1.0.0", "@daybrush/utils@^1.1.1", "@daybrush/utils@^1.10.3", "@daybrush/utils@^1.11.0", "@daybrush/utils@^1.3.1", "@daybrush/utils@^1.4.0", "@daybrush/utils@^1.6.0", "@daybrush/utils@^1.7.1", "@daybrush/utils@^1.9.1":
version "1.11.0"
resolved "https://registry.npmjs.org/@daybrush/utils/-/utils-1.11.0.tgz#ad23a431fdb8f95ab4bb34fb6d080f2f7997a988"
integrity sha512-/T0Oe7KkfUoCusFj1cJ6N+Tu+jFZXVkaKqDBcDY3P0goJfcfaT+4+oG8aHi4LDgBErNjP6uvC3IEOSMe2ka/yQ==
"@daybrush/utils@^0.10.0", "@daybrush/utils@^0.10.1", "@daybrush/utils@^0.11.0", "@daybrush/utils@^0.5.2", "@daybrush/utils@^0.7.1", "@daybrush/utils@^1.0.0", "@daybrush/utils@^1.1.1", "@daybrush/utils@^1.10.3", "@daybrush/utils@^1.11.0", "@daybrush/utils@^1.12.0", "@daybrush/utils@^1.12.1", "@daybrush/utils@^1.3.1", "@daybrush/utils@^1.4.0", "@daybrush/utils@^1.6.0", "@daybrush/utils@^1.7.1", "@daybrush/utils@^1.9.1":
version "1.12.1"
resolved "https://registry.npmjs.org/@daybrush/utils/-/utils-1.12.1.tgz#0daaa2a925fdfe8f42b4dbc202e22484878b64e2"
integrity sha512-VwtY+Pr+g2jpoXk9zQa5mmkXPG5XaHob1YJQZEs5XD35zma7QYaL5oWZY4dqRRhkD8YGonKms50kT9mThRkstg==

"@design-systems/utils@2.12.0":
version "2.12.0"
Expand Down Expand Up @@ -10674,13 +10674,13 @@ critters@0.0.16:
postcss "^8.3.7"
pretty-bytes "^5.3.0"

croact-css-styled@^1.1.7:
version "1.1.7"
resolved "https://registry.npmjs.org/croact-css-styled/-/croact-css-styled-1.1.7.tgz#51b9a2dcbf4696476f7a67ed99db2d74bf63044d"
integrity sha512-vJhWsE/BIGy9c82jl2klTDH9PH9l+PAi618+kRTIqVEVO+4VEsSLSF5vdASvQL3VBrPS5NXu9jJ4BYQ8Nq+lnw==
croact-css-styled@^1.1.8:
version "1.1.8"
resolved "https://registry.npmjs.org/croact-css-styled/-/croact-css-styled-1.1.8.tgz#518aee0e66c3b1f84dd73c16f57bfd3531b83173"
integrity sha512-CYR9eUsjDeDqT5+aSJN1L1zVhaDR8FOHh92u5rDwTbJ1l2pISGFqwg6L0Fy1GXDoh+tUmuS4zYHoAC21DR+gUQ==
dependencies:
"@daybrush/utils" "^1.0.0"
css-styled "~1.0.6"
css-styled "~1.0.7"
framework-utils "^1.1.0"

croact@^1.0.3:
Expand Down Expand Up @@ -10914,10 +10914,10 @@ css-styled@^1.0.1:
"@daybrush/utils" "^1.0.0"
string-hash "^1.1.3"

css-styled@~1.0.6:
version "1.0.6"
resolved "https://registry.npmjs.org/css-styled/-/css-styled-1.0.6.tgz#294757217d165feb4af5c8b9416c230642ce02a8"
integrity sha512-C5EOg7XwCA+b6D+F3eM36qevF+SIKahzIRfyt8Z+UugNnEMUKT2bRl/bu1a4P8Ilo/qY3Je5dRuanIMazy/tbA==
css-styled@~1.0.7:
version "1.0.7"
resolved "https://registry.npmjs.org/css-styled/-/css-styled-1.0.7.tgz#08bb17676b27e62b3978d1072c3dbbebb96edb51"
integrity sha512-ud6VclnjgwWxkxz3vrLTv7oEKP3xP/VeydTj5VAqa8zp5LFqKnHb7oSMgW+Z1R70Oz7sfBNEkv/H+yE9FhM4HQ==
dependencies:
"@daybrush/utils" "^1.11.0"

Expand Down Expand Up @@ -13852,12 +13852,12 @@ gensync@^1.0.0-beta.1, gensync@^1.0.0-beta.2:
resolved "https://registry.npmjs.org/gensync/-/gensync-1.0.0-beta.2.tgz"
integrity sha512-3hN7NaskYvMDLQY55gnW3NQ+mesEAepTqlg+VEbj7zzqEMBVNhzcGYYeqFo/TlYz6eQiFcp1HcsCZO+nGgS8zg==

gesto@^1.13.0, gesto@^1.13.1, gesto@^1.18.0, gesto@^1.5.1:
version "1.18.0"
resolved "https://registry.npmjs.org/gesto/-/gesto-1.18.0.tgz#d1de6cb8086d9f8b919b1f75c8fc78ed40ad2b07"
integrity sha512-XjGedc2Ix1Z8Py5IlFqupp0dg/2Iwq0/KiJITZ8zX1WfBSkD+G2j4J0ohWCEtmTdWWvJSi1Ql6iDq+NdIHYzVg==
gesto@^1.13.0, gesto@^1.13.1, gesto@^1.18.1, gesto@^1.5.1:
version "1.18.1"
resolved "https://registry.npmjs.org/gesto/-/gesto-1.18.1.tgz#8d026f4b7e4ba5118a0e1fdef411d33fc33a9cc9"
integrity sha512-1R7dozywz1NPqLvBlpLZdcIuq6xC+aW70364Jm5RicipO2pl3ruwCyzNxdgRHFfNJLIF4R3GaQpN9LvSbuNUvA==
dependencies:
"@daybrush/utils" "^1.7.1"
"@daybrush/utils" "^1.12.0"
"@scena/event-emitter" "^1.0.2"

get-caller-file@^2.0.1, get-caller-file@^2.0.5:
Expand Down Expand Up @@ -22557,12 +22557,12 @@ preact-context@^1.1.3:
resolved "https://registry.npmjs.org/preact-context/-/preact-context-1.1.4.tgz"
integrity sha512-gcCjPJ65R0MiW9hDu8W/3WAmyTElIvwLyEO6oLQiM6/TbLKLxCpBCWV8GJjx52TTEyUr60HLDcmoCXZlslelzQ==

preact-css-styled@^1.1.7:
version "1.1.7"
resolved "https://registry.npmjs.org/preact-css-styled/-/preact-css-styled-1.1.7.tgz#55f9293a35786811ac55d3cfa2e3930e84d6c45b"
integrity sha512-r+Rv6FRllNK9cpvWNIxDx6WkQ/Waoqan0y4fYgeD3gFDIy+pSXlk9H1aIQ1Gbhqvwy7W6MHkOcyB9EOjb4wWyA==
preact-css-styled@^1.1.8:
version "1.1.8"
resolved "https://registry.npmjs.org/preact-css-styled/-/preact-css-styled-1.1.8.tgz#63dbdbb8627978c30be63ee9f365406c0fe19e05"
integrity sha512-fxeyFNlz+jJPzC7IYL4Nrt7fH9IXb96tGqY35rGWD94MeBORcSxBm3VOvQNgcVoe7BqXdyUkqpeJd23kuUOWVA==
dependencies:
css-styled "~1.0.6"
css-styled "~1.0.7"
framework-utils "^1.1.0"

preact-render-to-string@^3.8.2:
Expand Down Expand Up @@ -23259,12 +23259,12 @@ react-compat-ruler@~0.8.1:
dependencies:
"@scena/react-ruler" "~0.9.1"

react-css-styled@^1.0.2, react-css-styled@^1.1.7, react-css-styled@~1.0.4:
version "1.1.7"
resolved "https://registry.npmjs.org/react-css-styled/-/react-css-styled-1.1.7.tgz#6328e9228129084c3c223ce8b1c105415b58070d"
integrity sha512-NaKzFbTOtsJ12q5coyYnx5L8Gq0ykbmIre1tbuBemUMYOiYFbBkk9+gWfBYzDxYY2C5ld5sBaiZXp+aunK51EQ==
react-css-styled@^1.0.2, react-css-styled@^1.1.8, react-css-styled@~1.0.4:
version "1.1.8"
resolved "https://registry.npmjs.org/react-css-styled/-/react-css-styled-1.1.8.tgz#8fac644fb04c9c4049d897f827511dceaf12cc0b"
integrity sha512-IdgkIcIBDeCavoI/51Msq/+yT4y8ThoPtguzKslvVc2ubYNvXa9K4W1T3HZdGVOv0jTXFQHD1FMbYa9kiEUFTQ==
dependencies:
css-styled "~1.0.6"
css-styled "~1.0.7"
framework-utils "^1.1.0"

react-docgen-typescript@^2.1.1:
Expand Down

0 comments on commit 15abedb

Please sign in to comment.