Unified postProcess()

This commit is contained in:
Luis Leiva 2017-11-12 20:46:54 +01:00
parent 3b96078e6c
commit 4bbbfa8baa
2 changed files with 18 additions and 8 deletions

View File

@ -44,8 +44,7 @@
elem.bind('touchstart', touchdownHandler);
elem.bind('touchmove', touchmoveHandler);
elem.bind('touchend', touchupHandler);
// Fix unwanted highlight "bug". Note: `this` is the actual DOM element.
this.onselectstart = function() { return false };
postProcess(elem, options);
}
@ -350,6 +349,8 @@
// Visually indicate whether this element is interactive or not.
elem[0].style.cursor = options.interactive ? 'pointer' : 'not-allowed';
}
// Fix unwanted highlight "bug". Note: `this` is the actual DOM element.
this.onselectstart = function() { return false };
};
/**

View File

@ -69,13 +69,8 @@
Event.add(elem, 'touchstart', touchdownHandler);
Event.add(elem, 'touchmove', touchmoveHandler);
Event.add(elem, 'touchend', touchupHandler);
// Fix unwanted highlight "bug".
elem.onselectstart = function() { return false };
if (options.cssCursors) {
// Visually indicate whether this element is interactive or not.
elem.style.cursor = options.interactive ? 'pointer' : 'not-allowed';
}
postProcess(elem, options);
}
var sketch = new jSketch(elem, options.graphics);
@ -120,6 +115,7 @@
var elem = this.elem, data = dataBind(elem)[namespace];
if (options) { // setter
data.options = deepExtend({}, Sketchable.prototype.defaults, options || {});
postProcess(elem);
return this;
} else { // getter
return data;
@ -355,6 +351,19 @@
}
};
/**
* @private
*/
function postProcess(elem, options) {
if (!options) options = dataBind(elem)[namespace].options;
if (options.cssCursors) {
// Visually indicate whether this element is interactive or not.
elem.style.cursor = options.interactive ? 'pointer' : 'not-allowed';
}
// Fix unwanted highlight "bug".
elem.onselectstart = function() { return false };
};
/**
* @private
*/