hippie/source/screens/demo/examples/ui/drag.njk

50 lines
1.3 KiB
Text
Raw Normal View History

2024-08-15 22:41:12 +02:00
---
title: Drag
tags:
- ui
2024-08-15 22:41:12 +02:00
---
{% set pageId = page.fileSlug %}
{% extends "hippie/_app_frame.njk" %}
2024-08-15 22:41:12 +02:00
{% block body %}
<header class="io pos_fix pin_top pin_right pin_left">
<button data-action="add">Add</button>
</header>
2024-08-15 22:49:11 +02:00
<div id="space"></div>
<div>
<div id="test">
<div class="body_frame">
{{ io.frameHeader('title-bar') }}
<main></main>
{{ io.frameFooter('mode-bar') }}
</div>
</div>
</div>
2024-08-15 22:41:12 +02:00
{% endblock %}
{%- block script %}
<script src="{{ pageBase }}js/_ui.js"></script>
2024-08-15 23:06:21 +02:00
<script>
// Get the space element
const space = document.getElementById('space');
const add = document.querySelector('[data-action=add]');
const test = document.getElementById('test');
2024-08-15 23:06:21 +02:00
// Add event listener to the add space button
add.addEventListener('click', () => {
2024-08-15 23:06:21 +02:00
const newDiv = new NewDiv(100, 100, 100, 100, getRandomColor());
newDiv.createDiv();
newDiv.appendToFrame(space);
});
// Create a new NewDiv instance
const newDiv = new NewDiv(100, 100, 200, 200, '#000');
2024-08-15 23:06:21 +02:00
newDiv.createDiv();
newDiv.appendToFrame(space);
const explorer = new NewDiv(256, 128, 800, 600, '#fff', test);
explorer.createDiv();
explorer.appendToFrame(space);
2024-08-15 23:06:21 +02:00
</script>
2024-08-15 22:41:12 +02:00
{% endblock %}