-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
160 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
<script lang="ts" setup> | ||
import { reactive, ref } from 'vue' | ||
import type { OuiDraggableEvent } from '@/lib' | ||
import { OuiDemo, OuiDraggable, OuiInputNumber } from '@/lib' | ||
const state = reactive({ | ||
x: 100, | ||
y: 100, | ||
}) | ||
const data = ref({}) | ||
function move(e: OuiDraggableEvent) { | ||
data.value = e | ||
state.x += e.deltaX | ||
state.y += e.deltaY | ||
} | ||
</script> | ||
|
||
<template> | ||
<h2>Draggable</h2> | ||
|
||
<OuiDraggable | ||
class="app-draggable-box" | ||
:style="{ | ||
left: `${state.x}px`, | ||
top: `${state.y}px`, | ||
}" | ||
@move="move" | ||
> | ||
{{ data }} | ||
</OuiDraggable> | ||
|
||
<OuiDemo :state="state"> | ||
<OuiInputNumber v-model="state.x" title="X" /> | ||
<OuiInputNumber v-model="state.y" title="Y" /> | ||
</OuiDemo> | ||
</template> | ||
|
||
<style> | ||
.app-draggable-box { | ||
background: purple; | ||
color: white; | ||
position: absolute; | ||
width: 200px; | ||
height:200px; | ||
} | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import type { LoggerInterface } from 'zeed' | ||
import { Logger } from 'zeed' | ||
|
||
const log: LoggerInterface = Logger('drag-util') | ||
|
||
export function isInsideScrollable(el?: HTMLElement | null, childOf?: HTMLElement) { | ||
// Figure out, if we are inside an element with custom scrolling | ||
|
||
// log('isInsideScrollable', el, childOf, childOf?.contains(el)) | ||
while (el != null) { | ||
if (childOf && (!childOf?.contains(el) || childOf.isSameNode(el))) | ||
return false | ||
|
||
if (el.dataset.noscroll === 'true') { | ||
log('exit noscroll') | ||
return true | ||
// break | ||
} | ||
if (el.tagName === 'BODY') { | ||
log('exit body') | ||
return true | ||
} | ||
const { overflow } = window.getComputedStyle(el) | ||
if (overflow.split(' ').some(o => o === 'auto' || o === 'scroll')) { | ||
log('exit scroll', el.scrollTop, overflow) | ||
// if (el.scrollTop <= 0) | ||
// return false | ||
return true | ||
} | ||
el = el.parentElement | ||
} | ||
return false | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters