MCPcopy Create free account
hub / github.com/OpenEndedGroup/Field2 / makeSlider

Function makeSlider

lib/web/drags.js:298–343  ·  view source on GitHub ↗
(rrRaph, w, h, get, setAndConstrain, onUp)

Source from the content-addressed store, hash-verified

296var insetW = 0;
297
298var makeSlider = function (rrRaph, w, h, get, setAndConstrain, onUp) {
299 for (var q = 1; q < 10; q++)
300 rrRaph.path("M" + (insetW + (q / 10.0) * (w - insetW * 2)) + "," + 1 + "L" + (insetW + (q / 10.0) * (w - insetW * 2)) + "," + (h)).attr({
301 stroke: "#222",
302 "stroke-width": 1
303 })
304
305 var p = rrRaph.path("M" + insetW + "," + (h / 2) + "L" + (w - insetW) + "," + (h / 2))
306 p.attr({
307 stroke: "#000",
308 "stroke-width": 1
309 });
310
311 var oo = dragThang(
312 rrRaph,
313 function () {
314 return [insetW + get() * (w - insetW * 2), h / 2]
315 },
316 function (originally, previously, now) {
317 var c = now[0];
318 if (c < insetW) c = insetW;
319 if (c > w - insetW) c = w - insetW;
320
321 console.log("set " + c)
322
323 var v = setAndConstrain((originally[0] - insetW) / (w - insetW * 2), (previously[0] - insetW) / (w - insetW * 2), (c - insetW) / (w - insetW * 2));
324
325 console.log("set part 2 " + v)
326
327 c = v * (w - insetW * 2) + insetW;
328
329 return [c, originally[1]];
330 },
331 10,
332 function () {
333 if (onUp) {
334 var u = onUp()
335 console.log(" ran onUp again got " + u);
336 return [insetW + u * (w - insetW * 2), h / 2]
337 }
338 else {
339 return
340 }
341 }
342 );
343};
344
345var makeDifferentialSlider = function (rrRaph, w, h, get, setAndConstrain, onUp) {
346 for (var q = 1; q < 10; q++)

Callers 3

insertFloatSliderFunction · 0.85
editMethod · 0.85

Calls 5

dragThangFunction · 0.85
pathMethod · 0.80
logMethod · 0.80
getFunction · 0.70
attrMethod · 0.45

Tested by

no test coverage detected