Ignore:
Timestamp:
2023-03-17T16:44:58+13:00 (13 months ago)
Author:
davidb
Message:

Initial work on having a winboxjs window working with interact.js

File:
1 edited

Legend:

Unmodified
Added
Removed
  • gs3-extensions/tabletop-dl/trunk/tabletop.html

    r37467 r37533  
    1818    <script src="winbox-dist/js/winbox.min.js"></script>
    1919    -->
     20    <link rel="stylesheet" href="src/winbox-with-interactjs/dist/css/winbox.min.css">
     21    <script src="src/winbox-with-interactjs/dist/js/winbox.min.js"></script>
    2022   
    2123    <script src="interactjs-dist/interact.min.js"></script>
     
    8183     
    8284    </div>
     85
     86    <!--
     87    <div id="my-own-window"
     88         style="position: absolute; left: 30px; top: 430px; width: 400px; height: 300px; background-color: red;">
     89    </div>
     90    -->
    8391   
     92     
    8493      </div>
    8594      <div class="row footer" style="display:none;">
     
    105114            });
    106115    });
     116
     117
     118    const win = new WinBox({
     119        id:    "my-winbox",
     120        title: 'My Window2',
     121        width: '400px',
     122        height: '400px',
     123    });
     124
     125    interact('#my-winbox')
     126        .draggable({
     127        // enable inertial throwing
     128        inertia: true,
     129        // keep the element within the area of it's parent
     130        modifiers: [
     131            interact.modifiers.restrictRect({
     132            restriction: 'parent',
     133            endOnly: true
     134            })
     135        ],
     136        // enable autoScroll
     137        autoScroll: true,
     138       
     139        listeners: {
     140            // call this function on every dragmove event
     141            move: dragMoveListener,
     142           
     143            // call this function on every dragend event
     144            end (event) {
     145            var textEl = event.target.querySelector('p')
     146           
     147            textEl && (textEl.textContent =
     148                   'moved a distance of ' +
     149                   (Math.sqrt(Math.pow(event.pageX - event.x0, 2) +
     150                          Math.pow(event.pageY - event.y0, 2) | 0))
     151                   .toFixed(2) + 'px')
     152            }
     153        }
     154        });
     155
    107156    });
    108157   
Note: See TracChangeset for help on using the changeset viewer.