mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-05 20:32:00 -05:00
Define View#isVisible() and use it to only handle key events if the focused view is not hidden.
This commit is contained in:
parent
65bfb091e1
commit
0fecbe50bc
2 changed files with 12 additions and 1 deletions
|
@ -70,7 +70,7 @@ var Key = this.Key = new function() {
|
||||||
key = keys[keyCode] || character.toLowerCase(),
|
key = keys[keyCode] || character.toLowerCase(),
|
||||||
handler = down ? 'onKeyDown' : 'onKeyUp',
|
handler = down ? 'onKeyDown' : 'onKeyUp',
|
||||||
view = View.focused,
|
view = View.focused,
|
||||||
scope = view && view._scope,
|
scope = view && view.isVisible() && view._scope,
|
||||||
tool = scope && scope.tool;
|
tool = scope && scope.tool;
|
||||||
keyMap[key] = down;
|
keyMap[key] = down;
|
||||||
if (tool && tool[handler]) {
|
if (tool && tool[handler]) {
|
||||||
|
|
|
@ -193,6 +193,17 @@ var View = this.View = Base.extend({
|
||||||
this._zoom = zoom;
|
this._zoom = zoom;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks whether the view is currently visible within the current browser
|
||||||
|
* viewport.
|
||||||
|
*
|
||||||
|
* @return {Boolean} Whether the view is visible.
|
||||||
|
*/
|
||||||
|
isVisible: function() {
|
||||||
|
// TODO: Take bounds into account if it's not the full canvas?
|
||||||
|
return DomElement.isVisible(this._canvas);
|
||||||
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {Point} point
|
* @param {Point} point
|
||||||
*/
|
*/
|
||||||
|
|
Loading…
Reference in a new issue