Hello there!
Yikes!
You are psychic, you READ ME!
Build contextmenu suited for both mobile devices and desktop without much overhead
License: MIT License
MouseEvent.clientX / TouchEvent.[...].clientX doesn't give accurate coordinates with grid layout: this makes positioning faulty.
When working with grid layout, MouseEvent.clientX/TouchEvent.touches[n].clientX
or MouseEvent.clientX/TouchEvent.targetTouches[n].clientX
or MouseEvent.clientX/TouchEvent.changedTouches[n].clientX
give coordinates relative to Window or client, meanwhile Event.currentTarget.offsetLeft
is relative to the column of the gridded element that forms the grid layout, while that element is being literally absolute (not css absolute) having a offsetLeft GridLayout.offsetLeft
of zero 0
.
More concisely, suppose we have a 3 column grid layout, say:
| COLUMN 1 | COLUMN 2 | COLUMN 3 |
Assume a mousedown event was triggered on COLUMN 3, COLUMN3.offsetLeft
will always equal 0
—not relative to window—in fact all the columns offsetLeft
equals 0
. While either MouseEvent.clientX/...
will always be relative to window, say, is equal 894
while window.innerWidth = 1024
.
This affects positioning when using the contextmenu in a grid layout, as CSS left position property is similar to the offsetLeft of the element.
To Reproduce
Steps to reproduce the behavior:
src, dest
as named in the examples.src
element and check the positioning of the dest
element from its CSS top, right, bottom, left
properties.Expected behavior
The CSS left property should be relative to window instead of the original elemnt it was defined as being relative to in the CSS declaration. This is the bug.
Desktop (please complete the following information):
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.