Skip to content

Commit

Permalink
Move DOMClippingEnabled to coreSettings.ts
Browse files Browse the repository at this point in the history
  • Loading branch information
huchenlei committed Nov 12, 2024
1 parent 40f9b88 commit 353bb70
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 16 deletions.
18 changes: 2 additions & 16 deletions src/scripts/domWidget.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// @ts-strict-ignore
import { useSettingStore } from '@/stores/settingStore'
import { app, ANIM_PREVIEW_WIDGET } from './app'
import { LGraphCanvas, LGraphNode, LiteGraph } from '@comfyorg/litegraph'
import type { Vector4 } from '@comfyorg/litegraph'
Expand Down Expand Up @@ -248,21 +249,6 @@ LGraphCanvas.prototype.computeVisibleNodes = function (): LGraphNode[] {
return visibleNodes
}

let enableDomClipping = true

export function addDomClippingSetting(): void {
app.ui.settings.addSetting({
id: 'Comfy.DOMClippingEnabled',
category: ['Comfy', 'Node', 'DOMClippingEnabled'],
name: 'Enable DOM element clipping (enabling may reduce performance)',
type: 'boolean',
defaultValue: enableDomClipping,
onChange(value) {
enableDomClipping = !!value
}
})
}

LGraphNode.prototype.addDOMWidget = function (
name: string,
type: string,
Expand Down Expand Up @@ -353,7 +339,7 @@ LGraphNode.prototype.addDOMWidget = function (
pointerEvents: app.canvas.read_only ? 'none' : 'auto'
})

if (enableDomClipping) {
if (useSettingStore().get('Comfy.DOMClippingEnabled')) {
element.style.clipPath = getClipPath(node, element, elRect)
element.style.willChange = 'clip-path'
}
Expand Down
7 changes: 7 additions & 0 deletions src/stores/coreSettings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -484,5 +484,12 @@ export const CORE_SETTINGS: SettingParams[] = [
type: 'boolean',
defaultValue: true,
versionAdded: '1.3.40'
},
{
id: 'Comfy.DOMClippingEnabled',
category: ['Comfy', 'Node', 'DOMClippingEnabled'],
name: 'Enable DOM element clipping (enabling may reduce performance)',
type: 'boolean',
defaultValue: true
}
]

0 comments on commit 353bb70

Please sign in to comment.