mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-11-07 23:16:52 +08:00
Updated buttons and added some event handlers
This commit is contained in:
@ -1,12 +1,18 @@
|
|||||||
(function(window, document, framework) {
|
(function(window, document, framework) {
|
||||||
framework.Button = function() {}
|
framework.Button = function() {}
|
||||||
|
|
||||||
|
// Process an the touchstart event and if this is a button,
|
||||||
|
// add the .active class so Android will show depressed
|
||||||
|
// button states.
|
||||||
framework.Button.prototype._onTouchStart = function(event) {
|
framework.Button.prototype._onTouchStart = function(event) {
|
||||||
console.log('Touch start!', event);
|
console.log('Touch start!', event);
|
||||||
if(event.target && event.target.classList.contains('button')) {
|
if(event.target && event.target.classList.contains('button')) {
|
||||||
event.target.classList.add('active');
|
event.target.classList.add('active');
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// Remove any active state on touch end/cancel/etc.
|
||||||
framework.Button.prototype._onTouchEnd = function(event) {
|
framework.Button.prototype._onTouchEnd = function(event) {
|
||||||
console.log('Touch end!', event);
|
console.log('Touch end!', event);
|
||||||
if(event.target && event.target.classList.contains('button')) {
|
if(event.target && event.target.classList.contains('button')) {
|
||||||
@ -16,5 +22,6 @@
|
|||||||
|
|
||||||
document.addEventListener('touchstart', framework.Button.prototype._onTouchStart);
|
document.addEventListener('touchstart', framework.Button.prototype._onTouchStart);
|
||||||
document.addEventListener('touchend', framework.Button.prototype._onTouchEnd);
|
document.addEventListener('touchend', framework.Button.prototype._onTouchEnd);
|
||||||
|
document.addEventListener('touchcancel', framework.Button.prototype._onTouchEnd);
|
||||||
|
|
||||||
})(this, document, this.FM = this.FM || {});
|
})(this, document, this.FM = this.FM || {});
|
||||||
|
|||||||
Reference in New Issue
Block a user