fix prev field for drag events and add onmousemove

Signed-off-by: Victor Seiji Hariki <victorseijih@gmail.com>

a

Signed-off-by: Victor Seiji Hariki <victorseijih@gmail.com>
This commit is contained in:
Victor Seiji Hariki 2022-11-20 23:23:08 -03:00
parent f460f43800
commit 217b89efef
2 changed files with 510 additions and 269 deletions

File diff suppressed because it is too large Load diff

View file

@ -46,6 +46,7 @@ function _mouse_observers() {
function _context_observers() {
return {
onmousemove: new Observer(),
left: _mouse_observers(),
middle: _mouse_observers(),
right: _mouse_observers(),
@ -230,12 +231,19 @@ window.onmousemove = (evn) => {
}
['window', 'canvas', 'world'].forEach((ctx) => {
mouse.listen[ctx].onmousemove.emit({
px: mouse[ctx].prev.x,
py: mouse[ctx].prev.y,
x: mouse[ctx].pos.x,
y: mouse[ctx].pos.y,
timestamp: new Date(),
});
['left', 'middle', 'right'].forEach((key) => {
// ondrag event
if (mouse[ctx].dragging[key] && mouse[ctx].dragging[key].drag)
mouse.listen[ctx][key].ondrag.emit({
px: mouse[ctx].prev.x,
py: mouse[ctx].prev.x,
py: mouse[ctx].prev.y,
x: mouse[ctx].pos.x,
y: mouse[ctx].pos.y,
timestamp: new Date(),
@ -245,7 +253,7 @@ window.onmousemove = (evn) => {
if (mouse[ctx].dragging[key])
mouse.listen[ctx][key].onpaint.emit({
px: mouse[ctx].prev.x,
py: mouse[ctx].prev.x,
py: mouse[ctx].prev.y,
x: mouse[ctx].pos.x,
y: mouse[ctx].pos.y,
timestamp: new Date(),
@ -282,3 +290,7 @@ mouse.listen.window.right.onpaintend.on(() =>
console.debug('mouse.listen.window.right.onpaintend')
);
*/
/**
* Mouse input processing
*/