Skip to content

Commit

Permalink
Move DOMClippingEnabled to coreSettings.ts (#1516)
Browse files Browse the repository at this point in the history
* Move DOMClippingEnabled to coreSettings.ts

* nit
  • Loading branch information
huchenlei authored Nov 12, 2024
1 parent feafbf9 commit 4bc7918
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 18 deletions.
2 changes: 0 additions & 2 deletions src/scripts/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import {
importA1111,
getLatentMetadata
} from './pnginfo'
import { addDomClippingSetting } from './domWidget'
import { createImageHost, calculateImageGrid } from './ui/imagePreview'
import { DraggableList } from './ui/draggableList'
import { applyTextReplacements, addStylesheet } from './utils'
Expand Down Expand Up @@ -1806,7 +1805,6 @@ export class ComfyApp {
])
await this.#loadExtensions()

addDomClippingSetting()
this.#addProcessMouseHandler()
this.#addProcessKeyHandler()
this.#addConfigureHandler()
Expand Down
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 @@ -514,5 +514,12 @@ export const CORE_SETTINGS: SettingParams[] = [
{ value: LinkMarkerShape.Arrow, text: 'Arrow' }
],
versionAdded: '1.3.42'
},
{
id: 'Comfy.DOMClippingEnabled',
category: ['Comfy', 'Node', 'DOMClippingEnabled'],
name: 'Enable DOM element clipping (enabling may reduce performance)',
type: 'boolean',
defaultValue: true
}
]

0 comments on commit 4bc7918

Please sign in to comment.