Skip to content

scaleFixed

固定元素的全局缩放,不随视图放大。

注意事项

需安装 scale-fixed 插件 才能使用,或直接安装 leafer-editor(已集成该插件)。

关键属性

scaleFixed: 'zoom-in' | number | false

固定元素的全局缩放,默认值为 false。

设置 'zoom-in' 或 数字 1 时, 表示元素不会跟随画面放大,但会跟随缩小(防止堆成一团)。

设置 0~1 之间的小数时,表示在画面缩小到这个缩放值的时候,元素才开始变小。

示例

元素不随画面放大

ts
// #scaleFixed [元素不随画面放大]
import { App, Rect } from 'leafer' // 自动导入 leafer-ui 和所有插件

const app = new App({ view: window, editor: {} })

app.tree.add(Rect.one({ editable: true, fill: '#FEB027', cornerRadius: [20, 0, 0, 20] }, 100, 100))
app.tree.add(Rect.one({
    scaleFixed: 'zoom-in', // 元素不随画面放大,但会跟随缩小 //
    editable: true, fill: '#FFE04B', cornerRadius: [0, 20, 20, 0]
}, 300, 100))

画布缩放到0.5时才跟随缩小

ts
// #scaleFixed [画布缩放到0.5时才跟随缩小]
import { App, Rect } from 'leafer' // 自动导入 leafer-ui 和所有插件

const app = new App({ view: window, editor: {} })

app.tree.add(Rect.one({ editable: true, fill: '#FEB027', cornerRadius: [20, 0, 0, 20] }, 100, 100))
app.tree.add(Rect.one({
    scaleFixed: 0.5, // 画布缩放到0.5时,才跟随缩小 //
    editable: true, fill: '#FFE04B', cornerRadius: [0, 20, 20, 0]
}, 300, 100))

Released under the MIT License.