-
Notifications
You must be signed in to change notification settings - Fork 764
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #310 from juliandescottes/Integrate-SelectedColors…
…Service Integrate selected colors service
- Loading branch information
Showing
26 changed files
with
195 additions
and
187 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
(function () { | ||
var ns = $.namespace('pskl.service'); | ||
|
||
var BUTTON_UNSET = null; | ||
|
||
/** | ||
* This service exists mostly due to a FF/IE bug. | ||
* For mousemove events, the button type is set to 0 (e.g. left button type) whatever was the | ||
* pressed button on mousedown. We use this service to cache the button type value on mousedown | ||
* and make it available to mousemove events. | ||
*/ | ||
ns.MouseStateService = function () { | ||
this.lastButtonPressed_ = BUTTON_UNSET; | ||
}; | ||
|
||
ns.MouseStateService.prototype.init = function () { | ||
$.subscribe(Events.MOUSE_EVENT, this.onMouseEvent_.bind(this)); | ||
}; | ||
|
||
ns.MouseStateService.prototype.isLeftButtonPressed = function () { | ||
return this.isMouseButtonPressed_(Constants.LEFT_BUTTON); | ||
}; | ||
|
||
ns.MouseStateService.prototype.isRightButtonPressed = function () { | ||
return this.isMouseButtonPressed_(Constants.RIGHT_BUTTON); | ||
}; | ||
|
||
ns.MouseStateService.prototype.isMiddleButtonPressed = function () { | ||
return this.isMouseButtonPressed_(Constants.MIDDLE_BUTTON); | ||
}; | ||
|
||
ns.MouseStateService.prototype.isMouseButtonPressed_ = function (mouseButton) { | ||
return this.lastButtonPressed_ != BUTTON_UNSET && this.lastButtonPressed_ == mouseButton; | ||
}; | ||
|
||
ns.MouseStateService.prototype.onMouseEvent_ = function(evt, mouseEvent) { | ||
if (mouseEvent.type == 'mousedown') { | ||
this.lastButtonPressed_ = mouseEvent.button; | ||
} else if (mouseEvent.type == 'mouseup') { | ||
this.lastButtonPressed_ = BUTTON_UNSET; | ||
} | ||
}; | ||
})(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.