-
-
Notifications
You must be signed in to change notification settings - Fork 385
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
during size changes, silently sync the DOM of cursor, select, hover p…
…ts. close #875.
- Loading branch information
Showing
7 changed files
with
357 additions
and
89 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
<!doctype html> | ||
<html> | ||
<head> | ||
<meta charset="utf-8"> | ||
<title>Keep selection and cursor in sync with resize (test)</title> | ||
<meta name="viewport" content="width=device-width, initial-scale=1"> | ||
|
||
<link rel="stylesheet" href="../dist/uPlot.min.css"> | ||
</head> | ||
<body> | ||
<script type="module"> | ||
import uPlot from "../dist/uPlot.esm.js"; | ||
|
||
let data = [ | ||
[0,1,2], | ||
[0,1,2], | ||
]; | ||
|
||
const opts = { | ||
title: "Maintain loc of cursor/select/hoverPts", | ||
width: 800, | ||
height: 800, | ||
scales: { | ||
x: { | ||
time: false, | ||
}, | ||
}, | ||
series: [ | ||
{}, | ||
{ | ||
stroke: "red", | ||
fill: "rgba(255,0,0,0.1)", | ||
}, | ||
], | ||
}; | ||
|
||
let u = new uPlot(opts, data, document.body); | ||
|
||
setTimeout(() => { | ||
u.setCursor({left: 200, top: 200}); | ||
u.cursor._lock = true; | ||
u.setSelect({ | ||
top: 0, | ||
height: u.bbox.height / uPlot.pxRatio, | ||
left: 100, | ||
width: 100, | ||
}); | ||
}); | ||
|
||
let dir = -1; | ||
let incr = 10; | ||
let minSize = 400; | ||
let maxSize = 800; | ||
|
||
let size = maxSize; | ||
|
||
setInterval(() => { | ||
if (dir == -1 && size < minSize) { | ||
dir = 1; | ||
size = minSize; | ||
return; | ||
} | ||
else if (dir == 1 && size > maxSize) { | ||
dir = -1; | ||
size = maxSize; | ||
return; | ||
} | ||
|
||
size += dir * incr; | ||
|
||
u.setSize({width: size, height: size}); | ||
}, 100); | ||
</script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.