Skip to content

[DISCUSS] Consider using the standard offsetX/offsetY instead of layerX/layerY for modern versions of Firefox #794

@plainheart

Description

@plainheart

Here is a stale caution in the following code,

https://github.com/ecomfe/zrender/blob/master/src/core/event.ts#L62-L75

According to CANIUSE and the release note of Firefox, the offsetX and offsetY have been supported since desktop Firefox 39

Support for MouseEvent.offsetX and MouseEvent.offsetY have been added on desktop (bug 69787, but not on Firefox for Android or Firefox OS (they will be added in Firefox 43).

And they have been also supported by Firefox for Android and Firefox OS since v43

Support for MouseEvent.offsetX and MouseEvent.offsetY have been activated on Firefox for Android and Firefox OS (bug 1204841).

One consideration why I want to propose to change

I can't dispatch a manual event with expected offsetX & offsetY through the constructor of MouseEvent.

Since zrender is still using the stale un-standard layerX/layerY in Firefox, I can't construct a MouseEvent object through

const event = new MouseEvent('click', {
    bubbles: false,
    layerX: 500, // it's private and readonly for Firefox, anyone can't specify it with the constructor
    layerY: 600
})

Motivation

I'm planning to support mixed event responding in the echarts for AMap plugin: echarts-extension-amap

All the time we can only choose one interactive layer from echarts layer and map layer because of the z-index issue.
But it's possible to get both of them interactive through re-dispatch event to another layer when one layer is clicked, scrolled and etc.

So I tried this feature in the branch feat-mixed-events. It can be working well in Chrome, but can't work in Firefox for the above issue.

A demo is available here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions