Don't show frames when they don't exist
This commit is contained in:
parent
7cf8ff7776
commit
c77942800c
39
src/main.js
39
src/main.js
|
|
@ -318,7 +318,9 @@ let startProps = {}
|
||||||
let actions = {
|
let actions = {
|
||||||
addShape: {
|
addShape: {
|
||||||
create: (parent, shape, ctx) => {
|
create: (parent, shape, ctx) => {
|
||||||
|
if (!parent.currentFrame?.exists) return;
|
||||||
if (shape.curves.length==0) return;
|
if (shape.curves.length==0) return;
|
||||||
|
console.log(parent.currentFrame)
|
||||||
redoStack.length = 0; // Clear redo stack
|
redoStack.length = 0; // Clear redo stack
|
||||||
let serializableCurves = []
|
let serializableCurves = []
|
||||||
for (let curve of shape.curves) {
|
for (let curve of shape.curves) {
|
||||||
|
|
@ -1339,6 +1341,7 @@ class Frame {
|
||||||
}
|
}
|
||||||
pointerList[this.idx] = this
|
pointerList[this.idx] = this
|
||||||
}
|
}
|
||||||
|
get exists() { return true }
|
||||||
saveState() {
|
saveState() {
|
||||||
startProps[this.idx] = structuredClone(this.keys)
|
startProps[this.idx] = structuredClone(this.keys)
|
||||||
}
|
}
|
||||||
|
|
@ -1366,6 +1369,30 @@ class Frame {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class TempFrame {
|
||||||
|
constructor() {}
|
||||||
|
get exists() { return false }
|
||||||
|
get idx() {
|
||||||
|
return "tempFrame"
|
||||||
|
}
|
||||||
|
get keys() {
|
||||||
|
return {}
|
||||||
|
}
|
||||||
|
get shapes() {
|
||||||
|
return []
|
||||||
|
}
|
||||||
|
get frameType() {
|
||||||
|
return "temp"
|
||||||
|
}
|
||||||
|
copy() {
|
||||||
|
return this
|
||||||
|
}
|
||||||
|
addShape() {}
|
||||||
|
removeShape() {}
|
||||||
|
}
|
||||||
|
|
||||||
|
const tempFrame = new TempFrame()
|
||||||
|
|
||||||
class Layer {
|
class Layer {
|
||||||
constructor(uuid) {
|
constructor(uuid) {
|
||||||
this.children = []
|
this.children = []
|
||||||
|
|
@ -1467,11 +1494,11 @@ class Layer {
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
for (let i=Math.min(num, this.frames.length-1); i>=0; i--) {
|
for (let i=Math.min(num, this.frames.length-1); i>=0; i--) {
|
||||||
if (this.frames[i].frameType == "keyframe") {
|
// if (this.frames[i].frameType == "keyframe") {
|
||||||
let tempFrame = this.frames[i].copy("tempFrame")
|
// let tempFrame = this.frames[i].copy("tempFrame")
|
||||||
tempFrame.frameType = "normal"
|
// tempFrame.frameType = "normal"
|
||||||
return tempFrame
|
return tempFrame
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -3073,6 +3100,7 @@ function stage() {
|
||||||
let mouse = getMousePos(stage, e)
|
let mouse = getMousePos(stage, e)
|
||||||
mouse = context.activeObject.transformMouse(mouse)
|
mouse = context.activeObject.transformMouse(mouse)
|
||||||
let selection;
|
let selection;
|
||||||
|
if (!context.activeObject.currentFrame?.exists) return;
|
||||||
switch (mode) {
|
switch (mode) {
|
||||||
case "rectangle":
|
case "rectangle":
|
||||||
case "ellipse":
|
case "ellipse":
|
||||||
|
|
@ -3269,6 +3297,7 @@ function stage() {
|
||||||
context.dragging = false
|
context.dragging = false
|
||||||
context.dragDirection = undefined
|
context.dragDirection = undefined
|
||||||
context.selectionRect = undefined
|
context.selectionRect = undefined
|
||||||
|
if (!context.activeObject.currentFrame?.exists) return
|
||||||
let mouse = getMousePos(stage, e)
|
let mouse = getMousePos(stage, e)
|
||||||
mouse = context.activeObject.transformMouse(mouse)
|
mouse = context.activeObject.transformMouse(mouse)
|
||||||
switch (mode) {
|
switch (mode) {
|
||||||
|
|
@ -3335,6 +3364,7 @@ function stage() {
|
||||||
stage.mouseup(e)
|
stage.mouseup(e)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
if (!context.activeObject.currentFrame?.exists) return;
|
||||||
switch (mode) {
|
switch (mode) {
|
||||||
case "draw":
|
case "draw":
|
||||||
stage.style.cursor = "default"
|
stage.style.cursor = "default"
|
||||||
|
|
@ -3486,6 +3516,7 @@ function stage() {
|
||||||
growBoundingBox(bbox, item.bbox())
|
growBoundingBox(bbox, item.bbox())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (bbox==undefined) break;
|
||||||
let point = getPointNearBox(bbox, mouse, 10)
|
let point = getPointNearBox(bbox, mouse, 10)
|
||||||
if (point) {
|
if (point) {
|
||||||
stage.style.cursor = `${point}-resize`
|
stage.style.cursor = `${point}-resize`
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue