mirror of https://github.com/luileito/jsketch.git
Ensure that events aren't handled when interactivity is disabled
This commit is contained in:
parent
f71f141387
commit
88496c0579
|
|
@ -390,8 +390,13 @@
|
||||||
// Don't handle right clicks.
|
// Don't handle right clicks.
|
||||||
if (e.which === 3) return false;
|
if (e.which === 3) return false;
|
||||||
|
|
||||||
var idx = e.identifier || 0;
|
var idx = e.identifier || 0,
|
||||||
var elem = $(e.target), data = elem.data(_ns), options = data.options;
|
elem = $(e.target),
|
||||||
|
data = elem.data(_ns),
|
||||||
|
options = data.options;
|
||||||
|
// Exit early if interactivity is disabled.
|
||||||
|
if (!options.interactive) return;
|
||||||
|
|
||||||
data.sketch.isDrawing = true;
|
data.sketch.isDrawing = true;
|
||||||
var p = getMousePos(e);
|
var p = getMousePos(e);
|
||||||
// Mark visually 1st point of stroke.
|
// Mark visually 1st point of stroke.
|
||||||
|
|
@ -418,8 +423,13 @@
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
function moveHandler(e) {
|
function moveHandler(e) {
|
||||||
var idx = e.identifier || 0;
|
var idx = e.identifier || 0,
|
||||||
var elem = $(e.target), data = elem.data(_ns), options = data.options;
|
elem = $(e.target),
|
||||||
|
data = elem.data(_ns),
|
||||||
|
options = data.options;
|
||||||
|
// Exit early if interactivity is disabled.
|
||||||
|
if (!options.interactive) return;
|
||||||
|
|
||||||
//if (!options.mouseupMovements && !data.sketch.isDrawing) return;
|
//if (!options.mouseupMovements && !data.sketch.isDrawing) return;
|
||||||
// This would grab all penup strokes AFTER drawing something on the canvas for the first time.
|
// This would grab all penup strokes AFTER drawing something on the canvas for the first time.
|
||||||
if ( (!options.mouseupMovements || data.strokes.length === 0) && !data.sketch.isDrawing ) return;
|
if ( (!options.mouseupMovements || data.strokes.length === 0) && !data.sketch.isDrawing ) return;
|
||||||
|
|
@ -440,8 +450,13 @@
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
function upHandler(e) {
|
function upHandler(e) {
|
||||||
var idx = e.identifier || 0;
|
var idx = e.identifier || 0,
|
||||||
var elem = $(e.target), data = elem.data(_ns), options = data.options;
|
elem = $(e.target),
|
||||||
|
data = elem.data(_ns),
|
||||||
|
options = data.options;
|
||||||
|
// Exit early if interactivity is disabled.
|
||||||
|
if (!options.interactive) return;
|
||||||
|
|
||||||
data.sketch.isDrawing = false;
|
data.sketch.isDrawing = false;
|
||||||
data.strokes.push(data.coords[idx]);
|
data.strokes.push(data.coords[idx]);
|
||||||
data.coords[idx] = [];
|
data.coords[idx] = [];
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue