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:
parent
f460f43800
commit
217b89efef
2 changed files with 510 additions and 269 deletions
741
js/index.js
741
js/index.js
File diff suppressed because it is too large
Load diff
16
js/input.js
16
js/input.js
|
@ -46,6 +46,7 @@ function _mouse_observers() {
|
||||||
|
|
||||||
function _context_observers() {
|
function _context_observers() {
|
||||||
return {
|
return {
|
||||||
|
onmousemove: new Observer(),
|
||||||
left: _mouse_observers(),
|
left: _mouse_observers(),
|
||||||
middle: _mouse_observers(),
|
middle: _mouse_observers(),
|
||||||
right: _mouse_observers(),
|
right: _mouse_observers(),
|
||||||
|
@ -230,12 +231,19 @@ window.onmousemove = (evn) => {
|
||||||
}
|
}
|
||||||
|
|
||||||
['window', 'canvas', 'world'].forEach((ctx) => {
|
['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) => {
|
['left', 'middle', 'right'].forEach((key) => {
|
||||||
// ondrag event
|
// ondrag event
|
||||||
if (mouse[ctx].dragging[key] && mouse[ctx].dragging[key].drag)
|
if (mouse[ctx].dragging[key] && mouse[ctx].dragging[key].drag)
|
||||||
mouse.listen[ctx][key].ondrag.emit({
|
mouse.listen[ctx][key].ondrag.emit({
|
||||||
px: mouse[ctx].prev.x,
|
px: mouse[ctx].prev.x,
|
||||||
py: mouse[ctx].prev.x,
|
py: mouse[ctx].prev.y,
|
||||||
x: mouse[ctx].pos.x,
|
x: mouse[ctx].pos.x,
|
||||||
y: mouse[ctx].pos.y,
|
y: mouse[ctx].pos.y,
|
||||||
timestamp: new Date(),
|
timestamp: new Date(),
|
||||||
|
@ -245,7 +253,7 @@ window.onmousemove = (evn) => {
|
||||||
if (mouse[ctx].dragging[key])
|
if (mouse[ctx].dragging[key])
|
||||||
mouse.listen[ctx][key].onpaint.emit({
|
mouse.listen[ctx][key].onpaint.emit({
|
||||||
px: mouse[ctx].prev.x,
|
px: mouse[ctx].prev.x,
|
||||||
py: mouse[ctx].prev.x,
|
py: mouse[ctx].prev.y,
|
||||||
x: mouse[ctx].pos.x,
|
x: mouse[ctx].pos.x,
|
||||||
y: mouse[ctx].pos.y,
|
y: mouse[ctx].pos.y,
|
||||||
timestamp: new Date(),
|
timestamp: new Date(),
|
||||||
|
@ -282,3 +290,7 @@ mouse.listen.window.right.onpaintend.on(() =>
|
||||||
console.debug('mouse.listen.window.right.onpaintend')
|
console.debug('mouse.listen.window.right.onpaintend')
|
||||||
);
|
);
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Mouse input processing
|
||||||
|
*/
|
||||||
|
|
Loading…
Reference in a new issue