fabricjs / fabric.js

Javascript Canvas Library, SVG-to-Canvas (& canvas-to-SVG) Parser

Home Page:http://fabricjs.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[Feature]: Interaction Based on Visual Layering Order

alwalxed opened this issue · comments

commented

CheckList

  • I agree to follow this project's Code of Conduct
  • I have read and followed the Contributing Guide
  • I have searched and referenced existing issues, feature requests and discussions
  • I am filing a FEATURE request.

Description

At present, interaction with active objects in Fabric.js is primarily determined by their selection status, rather than their visual layering order on the canvas. This feature request aims to align object interaction with their visual representation, allowing for more intuitive and contextually accurate user experiences.

Current State

Despite active objects being positioned behind other objects on the canvas, they maintain prioritization for interaction based solely on their selection status.

Additional Context

I attempted to address this discrepancy by deselecting and re-selecting the object. However, this workaround did not yield the desired outcome. It appears that the canvas continues to prioritize active objects regardless of their z-index position.

canvas.discardActiveObject();
canvas.sendBackwards(target);
canvas.requestRenderAll();
canvas.setActiveObject(target);
commented

Nevermind, I've discovered that the feature I requested has already been implemented

const canvas = new fabric.Canvas("spacebar-canvas", {
    preserveObjectStacking: true
});

Thanks to