mirror of https://github.com/luileito/jsketch.git
Added trigger API
This commit is contained in:
parent
36c55b8c9b
commit
af54d8f53f
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
|
@ -1,5 +1,5 @@
|
|||
/*!
|
||||
* jQuery sketchable | v2.3 | Luis A. Leiva | MIT license
|
||||
* jQuery sketchable | v2.4 | Luis A. Leiva | MIT license
|
||||
* A jQuery plugin for the jSketch drawing library.
|
||||
*/
|
||||
|
||||
|
|
@ -150,9 +150,28 @@
|
|||
handler: function(callback) {
|
||||
return this.each(function() {
|
||||
var elem = $(this), data = elem.data(namespace);
|
||||
|
||||
callback(elem, data);
|
||||
});
|
||||
},
|
||||
/**
|
||||
* Execute programmatically an event.
|
||||
* @param {string} event - Event name.
|
||||
* @return {object} jQuery
|
||||
* @memberof $.fn.sketchable
|
||||
* @example
|
||||
* $('canvas').sketchable('trigger', 'mouseup');
|
||||
*/
|
||||
trigger: function(event) {
|
||||
return this.each(function() {
|
||||
var elem = $(this), data = elem.data(namespace);
|
||||
|
||||
var evts = data.options.events;
|
||||
if (evts && typeof evts[event] === 'function') {
|
||||
evts[event](elem, data);
|
||||
}
|
||||
});
|
||||
},
|
||||
/**
|
||||
* Clears canvas <b>together with</b> associated strokes data.
|
||||
* @return {object} jQuery
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*!
|
||||
* Sketchable | v2.3 | Luis A. Leiva | MIT license
|
||||
* Sketchable | v2.4 | Luis A. Leiva | MIT license
|
||||
* A plugin for the jSketch drawing library.
|
||||
*/
|
||||
|
||||
|
|
@ -184,6 +184,24 @@
|
|||
|
||||
return this;
|
||||
},
|
||||
/**
|
||||
* Execute programmatically an event.
|
||||
* @param {string} event - Event name.
|
||||
* @return {Sketchable}
|
||||
* @memberof Sketchable
|
||||
* @example
|
||||
* var sketcher = new Sketchable('#my-canvas', { events: ... });
|
||||
* sketcher.trigger('mouseup');
|
||||
*/
|
||||
trigger: function(event) {
|
||||
var elem = this.elem, data = dataBind(elem)[namespace];
|
||||
|
||||
var evts = data.options.events;
|
||||
if (evts && typeof evts[event] === 'function') {
|
||||
evts[event](elem, data);
|
||||
}
|
||||
return this;
|
||||
},
|
||||
/**
|
||||
* Clears canvas <b>together with</b> associated strokes data.
|
||||
* @see Sketchable.handler
|
||||
|
|
|
|||
Loading…
Reference in New Issue