|
371 | 371 | attr(input0, "tabindex", "0");
|
372 | 372 | toggle_class(input0, "default", !/*$$props*/ ctx[24].class ? true : false);
|
373 | 373 | toggle_class(input0, "drag", true);
|
374 |
| - toggle_class(input0, "dragging", /*dragging*/ ctx[4]); |
375 |
| - toggle_class(input0, "fast", /*stepFactor*/ ctx[5] > 1 ? "fast" : ""); |
376 |
| - toggle_class(input0, "slow", /*stepFactor*/ ctx[5] < 1 ? "slow" : ""); |
377 |
| - toggle_class(input0, "focus", /*dragFocussed*/ ctx[2]); |
378 |
| - toggle_class(input0, "inactive", /*editing*/ ctx[6]); |
| 374 | + toggle_class(input0, "dragging", /*dragging*/ ctx[6]); |
| 375 | + toggle_class(input0, "fast", /*stepFactor*/ ctx[7] > 1 ? "fast" : ""); |
| 376 | + toggle_class(input0, "slow", /*stepFactor*/ ctx[7] < 1 ? "slow" : ""); |
| 377 | + toggle_class(input0, "focus", /*dragFocussed*/ ctx[4]); |
| 378 | + toggle_class(input0, "inactive", /*editing*/ ctx[8]); |
379 | 379 | attr(input1, "style", /*style*/ ctx[10]);
|
380 | 380 | attr(input1, "class", input1_class_value = "" + (null_to_empty(/*$$props*/ ctx[24].class) + " svelte-xg45mw"));
|
381 | 381 | attr(input1, "type", "text");
|
|
386 | 386 |
|
387 | 387 | toggle_class(input1, "default", !/*$$props*/ ctx[24].class ? true : false);
|
388 | 388 | toggle_class(input1, "edit", true);
|
389 |
| - toggle_class(input1, "editing", /*editing*/ ctx[6]); |
390 |
| - toggle_class(input1, "focus", /*editFocussed*/ ctx[3]); |
391 |
| - toggle_class(input1, "inactive", !/*editing*/ ctx[6]); |
| 389 | + toggle_class(input1, "editing", /*editing*/ ctx[8]); |
| 390 | + toggle_class(input1, "focus", /*editFocussed*/ ctx[5]); |
| 391 | + toggle_class(input1, "inactive", !/*editing*/ ctx[8]); |
392 | 392 | },
|
393 | 393 | m(target, anchor) {
|
394 | 394 | insert(target, input0, anchor);
|
395 | 395 | /*input0_binding*/ ctx[57](input0);
|
396 |
| - set_input_value(input0, /*visibleValue*/ ctx[7]); |
| 396 | + set_input_value(input0, /*visibleValue*/ ctx[9]); |
397 | 397 | insert(target, t, anchor);
|
398 | 398 | insert(target, input1, anchor);
|
399 | 399 | /*input1_binding*/ ctx[59](input1);
|
400 |
| - set_input_value(input1, /*visibleValue*/ ctx[7]); |
| 400 | + set_input_value(input1, /*visibleValue*/ ctx[9]); |
401 | 401 |
|
402 | 402 | if (!mounted) {
|
403 | 403 | dispose = [
|
404 | 404 | listen(window, "mousemove", function () {
|
405 |
| - if (is_function(/*dragging*/ ctx[4] ? /*dragmoveHandler*/ ctx[14] : "")) (/*dragging*/ ctx[4] ? /*dragmoveHandler*/ ctx[14] : "").apply(this, arguments); |
| 405 | + if (is_function(/*dragging*/ ctx[6] ? /*dragmoveHandler*/ ctx[14] : "")) (/*dragging*/ ctx[6] ? /*dragmoveHandler*/ ctx[14] : "").apply(this, arguments); |
406 | 406 | }),
|
407 | 407 | listen(window, "touchmove", function () {
|
408 |
| - if (is_function(/*dragging*/ ctx[4] ? /*touchmoveHandler*/ ctx[13] : "")) (/*dragging*/ ctx[4] ? /*touchmoveHandler*/ ctx[13] : "").apply(this, arguments); |
| 408 | + if (is_function(/*dragging*/ ctx[6] ? /*touchmoveHandler*/ ctx[13] : "")) (/*dragging*/ ctx[6] ? /*touchmoveHandler*/ ctx[13] : "").apply(this, arguments); |
409 | 409 | }),
|
410 | 410 | listen(window, "mouseup", stop_propagation(function () {
|
411 |
| - if (is_function(/*dragging*/ ctx[4] |
| 411 | + if (is_function(/*dragging*/ ctx[6] |
412 | 412 | ? /*mouseupHandler*/ ctx[16]
|
413 |
| - : /*editBlurHandler*/ ctx[20])) (/*dragging*/ ctx[4] |
| 413 | + : /*editBlurHandler*/ ctx[20])) (/*dragging*/ ctx[6] |
414 | 414 | ? /*mouseupHandler*/ ctx[16]
|
415 | 415 | : /*editBlurHandler*/ ctx[20]).apply(this, arguments);
|
416 | 416 | })),
|
417 | 417 | listen(window, "touchend", stop_propagation(function () {
|
418 |
| - if (is_function(/*dragging*/ ctx[4] |
| 418 | + if (is_function(/*dragging*/ ctx[6] |
419 | 419 | ? /*touchendHandler*/ ctx[15]
|
420 |
| - : /*editBlurHandler*/ ctx[20])) (/*dragging*/ ctx[4] |
| 420 | + : /*editBlurHandler*/ ctx[20])) (/*dragging*/ ctx[6] |
421 | 421 | ? /*touchendHandler*/ ctx[15]
|
422 | 422 | : /*editBlurHandler*/ ctx[20]).apply(this, arguments);
|
423 | 423 | })),
|
|
457 | 457 | attr(input0, "class", input0_class_value);
|
458 | 458 | }
|
459 | 459 |
|
460 |
| - if (dirty[0] & /*visibleValue*/ 128 && input0.value !== /*visibleValue*/ ctx[7]) { |
461 |
| - set_input_value(input0, /*visibleValue*/ ctx[7]); |
| 460 | + if (dirty[0] & /*visibleValue*/ 512 && input0.value !== /*visibleValue*/ ctx[9]) { |
| 461 | + set_input_value(input0, /*visibleValue*/ ctx[9]); |
462 | 462 | }
|
463 | 463 |
|
464 | 464 | if (dirty[0] & /*$$props, $$props*/ 16777216) {
|
|
469 | 469 | toggle_class(input0, "drag", true);
|
470 | 470 | }
|
471 | 471 |
|
472 |
| - if (dirty[0] & /*$$props, dragging*/ 16777232) { |
473 |
| - toggle_class(input0, "dragging", /*dragging*/ ctx[4]); |
| 472 | + if (dirty[0] & /*$$props, dragging*/ 16777280) { |
| 473 | + toggle_class(input0, "dragging", /*dragging*/ ctx[6]); |
474 | 474 | }
|
475 | 475 |
|
476 |
| - if (dirty[0] & /*$$props, stepFactor*/ 16777248) { |
477 |
| - toggle_class(input0, "fast", /*stepFactor*/ ctx[5] > 1 ? "fast" : ""); |
| 476 | + if (dirty[0] & /*$$props, stepFactor*/ 16777344) { |
| 477 | + toggle_class(input0, "fast", /*stepFactor*/ ctx[7] > 1 ? "fast" : ""); |
478 | 478 | }
|
479 | 479 |
|
480 |
| - if (dirty[0] & /*$$props, stepFactor*/ 16777248) { |
481 |
| - toggle_class(input0, "slow", /*stepFactor*/ ctx[5] < 1 ? "slow" : ""); |
| 480 | + if (dirty[0] & /*$$props, stepFactor*/ 16777344) { |
| 481 | + toggle_class(input0, "slow", /*stepFactor*/ ctx[7] < 1 ? "slow" : ""); |
482 | 482 | }
|
483 | 483 |
|
484 |
| - if (dirty[0] & /*$$props, dragFocussed*/ 16777220) { |
485 |
| - toggle_class(input0, "focus", /*dragFocussed*/ ctx[2]); |
| 484 | + if (dirty[0] & /*$$props, dragFocussed*/ 16777232) { |
| 485 | + toggle_class(input0, "focus", /*dragFocussed*/ ctx[4]); |
486 | 486 | }
|
487 | 487 |
|
488 |
| - if (dirty[0] & /*$$props, editing*/ 16777280) { |
489 |
| - toggle_class(input0, "inactive", /*editing*/ ctx[6]); |
| 488 | + if (dirty[0] & /*$$props, editing*/ 16777472) { |
| 489 | + toggle_class(input0, "inactive", /*editing*/ ctx[8]); |
490 | 490 | }
|
491 | 491 |
|
492 | 492 | if (dirty[0] & /*style*/ 1024) {
|
|
503 | 503 | attr(input1, "inputmode", input1_inputmode_value);
|
504 | 504 | }
|
505 | 505 |
|
506 |
| - if (dirty[0] & /*visibleValue*/ 128 && input1.value !== /*visibleValue*/ ctx[7]) { |
507 |
| - set_input_value(input1, /*visibleValue*/ ctx[7]); |
| 506 | + if (dirty[0] & /*visibleValue*/ 512 && input1.value !== /*visibleValue*/ ctx[9]) { |
| 507 | + set_input_value(input1, /*visibleValue*/ ctx[9]); |
508 | 508 | }
|
509 | 509 |
|
510 | 510 | if (dirty[0] & /*$$props, $$props*/ 16777216) {
|
|
515 | 515 | toggle_class(input1, "edit", true);
|
516 | 516 | }
|
517 | 517 |
|
518 |
| - if (dirty[0] & /*$$props, editing*/ 16777280) { |
519 |
| - toggle_class(input1, "editing", /*editing*/ ctx[6]); |
| 518 | + if (dirty[0] & /*$$props, editing*/ 16777472) { |
| 519 | + toggle_class(input1, "editing", /*editing*/ ctx[8]); |
520 | 520 | }
|
521 | 521 |
|
522 |
| - if (dirty[0] & /*$$props, editFocussed*/ 16777224) { |
523 |
| - toggle_class(input1, "focus", /*editFocussed*/ ctx[3]); |
| 522 | + if (dirty[0] & /*$$props, editFocussed*/ 16777248) { |
| 523 | + toggle_class(input1, "focus", /*editFocussed*/ ctx[5]); |
524 | 524 | }
|
525 | 525 |
|
526 |
| - if (dirty[0] & /*$$props, editing*/ 16777280) { |
527 |
| - toggle_class(input1, "inactive", !/*editing*/ ctx[6]); |
| 526 | + if (dirty[0] & /*$$props, editing*/ 16777472) { |
| 527 | + toggle_class(input1, "inactive", !/*editing*/ ctx[8]); |
528 | 528 | }
|
529 | 529 | },
|
530 | 530 | i: noop,
|
|
600 | 600 | let dragElement, editElement;
|
601 | 601 | let dragFocussed = false;
|
602 | 602 | let editFocussed = false;
|
| 603 | + let focussed = false; |
603 | 604 | let dragging = false;
|
604 | 605 | let wasActiveOnClick, hasMoved, clickX, clickY;
|
605 | 606 | let stepFactor = 1;
|
|
628 | 629 | function dragstartHandler(ev) {
|
629 | 630 | dispatch("consoleLog", ev.type);
|
630 | 631 | wasActiveOnClick = document.activeElement === dragElement;
|
631 |
| - $$invalidate(4, dragging = true); |
| 632 | + $$invalidate(6, dragging = true); |
632 | 633 | dragElement.focus();
|
633 | 634 | hasMoved = false;
|
634 | 635 | clickX = isTouchDevice ? ev.touches[0].clientX : ev.clientX;
|
635 | 636 | clickY = isTouchDevice ? ev.touches[0].clientY : ev.clientY;
|
636 |
| - $$invalidate(4, dragging = true); |
| 637 | + $$invalidate(6, dragging = true); |
637 | 638 | updateValues(value);
|
638 | 639 | }
|
639 | 640 |
|
|
677 | 678 | dispatch("dragend");
|
678 | 679 | }
|
679 | 680 |
|
680 |
| - $$invalidate(4, dragging = false); |
| 681 | + $$invalidate(6, dragging = false); |
681 | 682 |
|
682 | 683 | // start editing only if element was already focussed on mousedown and no dragging was done
|
683 | 684 | if (wasActiveOnClick && !hasMoved) {
|
|
687 | 688 |
|
688 | 689 | function dragFocusHandler(ev) {
|
689 | 690 | dispatch("consoleLog", ev.type);
|
690 |
| - $$invalidate(2, dragFocussed = true); |
| 691 | + $$invalidate(4, dragFocussed = true); |
| 692 | + updateFocussed(); |
691 | 693 | }
|
692 | 694 |
|
693 | 695 | function dragBlurHandler(ev) {
|
694 | 696 | dispatch("consoleLog", ev.type);
|
695 |
| - $$invalidate(2, dragFocussed = false); |
| 697 | + $$invalidate(4, dragFocussed = false); |
| 698 | + updateFocussed(); |
696 | 699 | }
|
697 | 700 |
|
698 | 701 | function editFocusHandler(ev) {
|
699 | 702 | dispatch("consoleLog", ev.type);
|
700 |
| - $$invalidate(3, editFocussed = true); |
| 703 | + $$invalidate(5, editFocussed = true); |
| 704 | + updateFocussed(); |
701 | 705 | }
|
702 | 706 |
|
703 | 707 | function editBlurHandler(ev) {
|
704 | 708 | dispatch("consoleLog", ev.type);
|
| 709 | + $$invalidate(5, editFocussed = false); |
| 710 | + updateFocussed(); |
705 | 711 | stopEditing();
|
706 | 712 | }
|
707 | 713 |
|
|
769 | 775 | }
|
770 | 776 | }
|
771 | 777 |
|
| 778 | + async function updateFocussed() { |
| 779 | + await tick(); |
| 780 | + |
| 781 | + if (document.activeElement == dragElement || document.activeElement == editElement) { |
| 782 | + if (!focussed) { |
| 783 | + focussed = true; |
| 784 | + dispatch("focus"); |
| 785 | + console.log("Focus"); |
| 786 | + } |
| 787 | + } else { |
| 788 | + if (focussed) { |
| 789 | + focussed = false; |
| 790 | + dispatch("blur"); |
| 791 | + console.log("Blur"); |
| 792 | + } |
| 793 | + } |
| 794 | + } |
| 795 | + |
772 | 796 | async function startEditing() {
|
773 |
| - $$invalidate(6, editing = true); |
| 797 | + $$invalidate(8, editing = true); |
774 | 798 |
|
775 | 799 | //preciseValue = parseFloat(visibleValue);
|
776 | 800 | await tick();
|
|
782 | 806 |
|
783 | 807 | function stopEditing() {
|
784 | 808 | if (editing) {
|
785 |
| - $$invalidate(3, editFocussed = false); |
786 |
| - $$invalidate(6, editing = false); |
| 809 | + $$invalidate(8, editing = false); |
787 | 810 |
|
788 | 811 | if (parse) {
|
789 | 812 | preciseValue = parse(visibleValue);
|
|
826 | 849 | function updateValues(val) {
|
827 | 850 | preciseValue = parseFloat(val);
|
828 | 851 | preciseValue = keepInRange(preciseValue);
|
829 |
| - $$invalidate(7, visibleValue = Math.round((preciseValue - min) / step) * step + min); |
| 852 | + $$invalidate(9, visibleValue = Math.round((preciseValue - min) / step) * step + min); |
830 | 853 |
|
831 | 854 | if (format) {
|
832 |
| - $$invalidate(7, visibleValue = format(visibleValue)); |
| 855 | + $$invalidate(9, visibleValue = format(visibleValue)); |
833 | 856 | } else {
|
834 |
| - $$invalidate(7, visibleValue = visibleValue.toFixed(decimals)); |
| 857 | + $$invalidate(9, visibleValue = visibleValue.toFixed(decimals)); |
835 | 858 | }
|
836 | 859 |
|
837 | 860 | $$invalidate(25, value = roundToPrecision(preciseValue));
|
|
901 | 924 | function input0_binding($$value) {
|
902 | 925 | binding_callbacks[$$value ? "unshift" : "push"](() => {
|
903 | 926 | dragElement = $$value;
|
904 |
| - $$invalidate(8, dragElement); |
| 927 | + $$invalidate(2, dragElement); |
905 | 928 | });
|
906 | 929 | }
|
907 | 930 |
|
908 | 931 | function input0_input_handler() {
|
909 | 932 | visibleValue = this.value;
|
910 |
| - $$invalidate(7, visibleValue); |
| 933 | + $$invalidate(9, visibleValue); |
911 | 934 | }
|
912 | 935 |
|
913 | 936 | function input1_binding($$value) {
|
914 | 937 | binding_callbacks[$$value ? "unshift" : "push"](() => {
|
915 | 938 | editElement = $$value;
|
916 |
| - $$invalidate(9, editElement); |
| 939 | + $$invalidate(3, editElement); |
917 | 940 | });
|
918 | 941 | }
|
919 | 942 |
|
920 | 943 | function input1_input_handler() {
|
921 | 944 | visibleValue = this.value;
|
922 |
| - $$invalidate(7, visibleValue); |
| 945 | + $$invalidate(9, visibleValue); |
923 | 946 | }
|
924 | 947 |
|
925 | 948 | $$self.$$set = $$new_props => {
|
|
950 | 973 | };
|
951 | 974 |
|
952 | 975 | $$self.$$.update = () => {
|
953 |
| - if ($$self.$$.dirty[0] & /*editing, dragging, value*/ 33554512) { |
| 976 | + if ($$self.$$.dirty[0] & /*dragElement, editElement*/ 12) { |
954 | 977 | // updaters --------------------------------
|
| 978 | + // this will init focussed variable |
| 979 | + if (dragElement && editElement) { |
| 980 | + updateFocussed(); |
| 981 | + } |
| 982 | + } |
| 983 | + |
| 984 | + if ($$self.$$.dirty[0] & /*editing, dragging, value*/ 33554752) { |
955 | 985 | {
|
956 | 986 | if (!editing && !dragging) {
|
957 | 987 | updateValues(value);
|
958 | 988 | }
|
959 | 989 | }
|
960 | 990 | }
|
961 | 991 |
|
962 |
| - if ($$self.$$.dirty[0] & /*dragFocussed, editing*/ 68 | $$self.$$.dirty[1] & /*altPressed, shiftPressed*/ 98304) { |
| 992 | + if ($$self.$$.dirty[0] & /*dragFocussed, editing*/ 272 | $$self.$$.dirty[1] & /*altPressed, shiftPressed*/ 98304) { |
963 | 993 | {
|
964 |
| - $$invalidate(5, stepFactor = 1); |
| 994 | + $$invalidate(7, stepFactor = 1); |
965 | 995 |
|
966 | 996 | if (dragFocussed && !editing) {
|
967 | 997 | if (altPressed && shiftPressed) {
|
968 |
| - $$invalidate(5, stepFactor = 10); |
| 998 | + $$invalidate(7, stepFactor = 10); |
969 | 999 | } else if (altPressed) {
|
970 |
| - $$invalidate(5, stepFactor = 0.1); |
| 1000 | + $$invalidate(7, stepFactor = 0.1); |
971 | 1001 | }
|
972 | 1002 | }
|
973 | 1003 | }
|
974 | 1004 | }
|
975 | 1005 |
|
976 |
| - if ($$self.$$.dirty[0] & /*dragging*/ 16 | $$self.$$.dirty[1] & /*horizontal, vertical, htmlNode, cursor, defaultCursor, htmlNodeOriginalCursor*/ 933984) { |
| 1006 | + if ($$self.$$.dirty[0] & /*dragging*/ 64 | $$self.$$.dirty[1] & /*horizontal, vertical, htmlNode, cursor, defaultCursor, htmlNodeOriginalCursor*/ 933984) { |
977 | 1007 | {
|
978 | 1008 | // let cursorClass = horizontal
|
979 | 1009 | // ? vertical
|
|
994 | 1024 | }
|
995 | 1025 | }
|
996 | 1026 |
|
997 |
| - if ($$self.$$.dirty[0] & /*style, dragFocussed, editFocussed, editing, stepFactor, dragging*/ 1148 | $$self.$$.dirty[1] & /*mainStyle, focusStyle, fastStyle, slowStyle, draggingStyle, editingStyle, cursor, defaultCursor*/ 556800) { |
| 1027 | + if ($$self.$$.dirty[0] & /*style, dragFocussed, editFocussed, editing, stepFactor, dragging*/ 1520 | $$self.$$.dirty[1] & /*mainStyle, focusStyle, fastStyle, slowStyle, draggingStyle, editingStyle, cursor, defaultCursor*/ 556800) { |
998 | 1028 | {
|
999 | 1029 | $$invalidate(10, style = mainStyle ?? "");
|
1000 | 1030 |
|
|
1022 | 1052 | return [
|
1023 | 1053 | min,
|
1024 | 1054 | step,
|
| 1055 | + dragElement, |
| 1056 | + editElement, |
1025 | 1057 | dragFocussed,
|
1026 | 1058 | editFocussed,
|
1027 | 1059 | dragging,
|
1028 | 1060 | stepFactor,
|
1029 | 1061 | editing,
|
1030 | 1062 | visibleValue,
|
1031 |
| - dragElement, |
1032 |
| - editElement, |
1033 | 1063 | style,
|
1034 | 1064 | touchstartHandler,
|
1035 | 1065 | dragstartHandler,
|
|
0 commit comments