Skip to content

Layer ​

Key Methods ​

toTop() ​

Move selected elements to the top layer (within their parent Group), Now supports compatibility with the zIndex logic.

toBottom() ​

Move selected elements to the bottom layer (within their parent Group), Now supports compatibility with the zIndex logic.

Belongs to ​

Editor Element ​

Example ​

Bring element to top layer ​

ts
// #图形编辑器 [变动层级 toTop()]
import { App, Rect } from 'leafer-ui'
import '@leafer-in/editor' // 导入图形编辑器插件
import '@leafer-in/viewport' // 导入视口插件 (可选)

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({ editable: true, fill: '#FFE04B', cornerRadius: [0, 20, 20, 0] }, 150, 100))

app.editor.select(app.tree.children[0])

setTimeout(() => {

    // 将元素置于顶层 
    app.editor.toTop() 

}, 1000)

Released under the MIT License.