mirror of
https://github.com/excalidraw/excalidraw.git
synced 2025-05-03 10:00:07 -04:00
fix: Support Excalidraw inside scrollable container (#3018)
* refactor: remove position fixed from excalidraw container, modal and stats * remove unused css * remove position fixed from toast and scroll to content * Make excal interactable by fixing offsets and set popover as fixed since position needs to be calculate from viewport top * Assign 200px less than height of Excalidraw to the selected shapes actions o UI doesn't overflow * update changelog, readme and package.json
This commit is contained in:
parent
5b343a9d46
commit
830fb64a25
13 changed files with 73 additions and 44 deletions
|
@ -12,6 +12,20 @@ The change should be grouped under one of the below section and must contain PR
|
|||
Please add the latest change on the top under the correct section.
|
||||
-->
|
||||
|
||||
## 0.3.1
|
||||
|
||||
## Excalidraw API
|
||||
|
||||
### Fixes
|
||||
|
||||
- Support Excalidraw inside scrollable container [#3018](https://github.com/excalidraw/excalidraw/pull/3018)
|
||||
|
||||
## Excalidraw Library
|
||||
|
||||
### Fixes
|
||||
|
||||
- Allow to toggle between modes when view only mode to make UI consistent [#3009](https://github.com/excalidraw/excalidraw/pull/3009)
|
||||
|
||||
## 0.3.0
|
||||
|
||||
## Excalidraw API
|
||||
|
|
|
@ -37,18 +37,18 @@ You can update the value of `PUBLIC_URL` if you want to serve it from a differen
|
|||
1. If you are using a Web bundler (for instance, Webpack), you can import it as an ES6 module as shown below
|
||||
|
||||
```js
|
||||
import React, { useEffect, useState, createRef } from "react";
|
||||
import React, { useEffect, useState, useRef } from "react";
|
||||
import Excalidraw from "@excalidraw/excalidraw";
|
||||
import InitialData from "./initialData";
|
||||
|
||||
import "./styles.css";
|
||||
import "./styles.scss";
|
||||
|
||||
export default function App() {
|
||||
const excalidrawRef = createRef();
|
||||
|
||||
const excalidrawRef = useRef(null);
|
||||
const excalidrawWrapperRef = useRef(null);
|
||||
const [dimensions, setDimensions] = useState({
|
||||
width: window.innerWidth,
|
||||
height: window.innerHeight,
|
||||
width: undefined,
|
||||
height: undefined,
|
||||
});
|
||||
|
||||
const [viewModeEnabled, setViewModeEnabled] = useState(false);
|
||||
|
@ -56,17 +56,21 @@ export default function App() {
|
|||
const [gridModeEnabled, setGridModeEnabled] = useState(false);
|
||||
|
||||
useEffect(() => {
|
||||
setDimensions({
|
||||
width: excalidrawWrapperRef.current.getBoundingClientRect().width,
|
||||
height: excalidrawWrapperRef.current.getBoundingClientRect().height,
|
||||
});
|
||||
const onResize = () => {
|
||||
setDimensions({
|
||||
width: window.innerWidth,
|
||||
height: window.innerHeight,
|
||||
width: excalidrawWrapperRef.current.getBoundingClientRect().width,
|
||||
height: excalidrawWrapperRef.current.getBoundingClientRect().height,
|
||||
});
|
||||
};
|
||||
|
||||
window.addEventListener("resize", onResize);
|
||||
|
||||
return () => window.removeEventListener("resize", onResize);
|
||||
}, []);
|
||||
}, [excalidrawWrapperRef]);
|
||||
|
||||
const updateScene = () => {
|
||||
const sceneData = {
|
||||
|
@ -102,6 +106,7 @@ export default function App() {
|
|||
|
||||
return (
|
||||
<div className="App">
|
||||
<h1> Excalidraw Example</h1>
|
||||
<div className="button-wrapper">
|
||||
<button className="update-scene" onClick={updateScene}>
|
||||
Update Scene
|
||||
|
@ -139,7 +144,7 @@ export default function App() {
|
|||
Grid mode
|
||||
</label>
|
||||
</div>
|
||||
<div className="excalidraw-wrapper">
|
||||
<div className="excalidraw-wrapper" ref={excalidrawWrapperRef}>
|
||||
<Excalidraw
|
||||
ref={excalidrawRef}
|
||||
width={dimensions.width}
|
||||
|
@ -148,7 +153,6 @@ export default function App() {
|
|||
onChange={(elements, state) =>
|
||||
console.log("Elements :", elements, "State : ", state)
|
||||
}
|
||||
user={{ name: "Excalidraw User" }}
|
||||
onPointerUpdate={(payload) => console.log(payload)}
|
||||
onCollabButtonClick={() =>
|
||||
window.alert("You clicked on collab button")
|
||||
|
|
2
src/packages/excalidraw/package-lock.json
generated
2
src/packages/excalidraw/package-lock.json
generated
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "@excalidraw/excalidraw",
|
||||
"version": "0.3.0",
|
||||
"version": "0.3.1",
|
||||
"lockfileVersion": 1,
|
||||
"requires": true,
|
||||
"dependencies": {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "@excalidraw/excalidraw",
|
||||
"version": "0.3.0",
|
||||
"version": "0.3.1",
|
||||
"main": "dist/excalidraw.min.js",
|
||||
"files": [
|
||||
"dist/*"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue