Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function drawShape($step: Step, $geopad: Geopad, goal: string, shape: string,
expand = false) {
// `shape` should be names of a polygon, segment or line.
const lines = flatten(
words(shape).map(s => $geopad.model[s].edges || $geopad.model[s]));
$geopad.setActiveTool('line');
$geopad.waitForPaths(lines, {
onCorrect(path, i) {
if (expand) expandSegment($geopad, path.points, lines[i]);
},
onIncorrect() {
$step.addHint('incorrect', {force: true});
},
onHint() {
$step.addHint('draw-hint', {force: true});
},
onComplete(afterError) {
if (!afterError) $step.addHint('correct');
$step.score(goal);
export function bindEvent($el: ElementView, event: string, fn: EventCallback,
options?: EventListenerOptions) {
if (event in aliases) {
const events = words(aliases[event]);
// Note that the mouse event aliases don't pass through makeMouseEvent()!
for (const e of events) $el._el.addEventListener(e, fn, options);
} else if (event in customEvents) {
customEvents[event]($el);
} else {
$el._el.addEventListener(event, fn, options);
}
}
off(events, callback) {
for (const e of words(events)) removeEvent(this, e, callback);
}
trigger(events, args = {}) {
for (const e of words(events)) {
if (!this._events[e]) return;
for (const fn of this._events[e]) fn.call(this, args);
}
}
on(events, callback, options = undefined) {
for (const e of words(events)) createEvent(this, e, callback, options);
}