mirror of
https://github.com/Sped0n/bridget.git
synced 2026-04-22 14:09:30 -07:00
now html element can be generated by typescript
This commit is contained in:
@@ -1,25 +1,17 @@
|
|||||||
import { overlayEnable } from './overlay'
|
import { overlayEnable } from './overlay'
|
||||||
import {
|
import {
|
||||||
|
calcImageIndex,
|
||||||
|
center,
|
||||||
|
createImgElement,
|
||||||
|
delay,
|
||||||
FIFO,
|
FIFO,
|
||||||
layerPosSet,
|
layerPosSet,
|
||||||
center,
|
type position
|
||||||
type position,
|
|
||||||
createImgElement,
|
|
||||||
calcImageIndex,
|
|
||||||
delay
|
|
||||||
} from './utils'
|
} from './utils'
|
||||||
import { thresholdSensitivityArray, thresholdIndex } from './thresholdCtl'
|
import { thresholdIndex, thresholdSensitivityArray } from './thresholdCtl'
|
||||||
import { imgIndexSpanUpdate } from './indexDisp'
|
import { imgIndexSpanUpdate } from './indexDisp'
|
||||||
import { imagesArrayLen, imagesArray } from './dataFetch'
|
import { imagesArray, imagesArrayLen } from './dataFetch'
|
||||||
|
import { layers } from './elemGen'
|
||||||
// get layer divs
|
|
||||||
export const layers: HTMLDivElement[] = [
|
|
||||||
document.getElementById('layer1') as HTMLDivElement,
|
|
||||||
document.getElementById('layer2') as HTMLDivElement,
|
|
||||||
document.getElementById('layer3') as HTMLDivElement,
|
|
||||||
document.getElementById('layer4') as HTMLDivElement,
|
|
||||||
document.getElementById('layer5') as HTMLDivElement
|
|
||||||
]
|
|
||||||
|
|
||||||
// top layer position caching
|
// top layer position caching
|
||||||
let topLayerPos: number[] = [0, 0]
|
let topLayerPos: number[] = [0, 0]
|
||||||
|
|||||||
49
assets/ts/elemGen.ts
Normal file
49
assets/ts/elemGen.ts
Normal file
@@ -0,0 +1,49 @@
|
|||||||
|
// get components of overlay
|
||||||
|
export let overlayCursor: HTMLDivElement
|
||||||
|
export let cursorInnerContent: HTMLDivElement
|
||||||
|
export let layers: HTMLDivElement[]
|
||||||
|
|
||||||
|
const passDesktopElements = (): void => {
|
||||||
|
overlayCursor = document
|
||||||
|
.getElementsByClassName('overlay_cursor')
|
||||||
|
.item(0) as HTMLDivElement
|
||||||
|
cursorInnerContent = document
|
||||||
|
.getElementsByClassName('cursor_innerText')
|
||||||
|
.item(0) as HTMLDivElement
|
||||||
|
layers = [
|
||||||
|
document.getElementById('layer1') as HTMLDivElement,
|
||||||
|
document.getElementById('layer2') as HTMLDivElement,
|
||||||
|
document.getElementById('layer3') as HTMLDivElement,
|
||||||
|
document.getElementById('layer4') as HTMLDivElement,
|
||||||
|
document.getElementById('layer5') as HTMLDivElement
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
|
const createLayerDiv = (layerID: number): HTMLDivElement => {
|
||||||
|
const layerDiv: HTMLDivElement = document.createElement('div')
|
||||||
|
layerDiv.className = 'image_container'
|
||||||
|
layerDiv.id = `layer${layerID}`
|
||||||
|
layerDiv.dataset.status = 'null'
|
||||||
|
return layerDiv
|
||||||
|
}
|
||||||
|
|
||||||
|
const createCursorDiv = (): HTMLDivElement => {
|
||||||
|
const cursorDiv: HTMLDivElement = document.createElement('div')
|
||||||
|
cursorDiv.className = 'overlay_cursor'
|
||||||
|
const innerTextDiv: HTMLDivElement = document.createElement('div')
|
||||||
|
innerTextDiv.className = 'cursor_innerText'
|
||||||
|
cursorDiv.appendChild(innerTextDiv)
|
||||||
|
return cursorDiv
|
||||||
|
}
|
||||||
|
|
||||||
|
export const createDesktopElements = (): void => {
|
||||||
|
const mainDiv = document.getElementById('main') as HTMLDivElement
|
||||||
|
mainDiv.appendChild(createCursorDiv())
|
||||||
|
const desktopWrapper: HTMLDivElement = document.createElement('div')
|
||||||
|
desktopWrapper.className = 'desktopWrapper'
|
||||||
|
for (let i = 0; i < 15; i++) {
|
||||||
|
desktopWrapper.appendChild(createLayerDiv(i))
|
||||||
|
}
|
||||||
|
mainDiv.appendChild(desktopWrapper)
|
||||||
|
passDesktopElements()
|
||||||
|
}
|
||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import { createDesktopElements } from './elemGen'
|
||||||
import { imgIndexSpanUpdate } from './indexDisp'
|
import { imgIndexSpanUpdate } from './indexDisp'
|
||||||
import { trackMouseInit } from './desktop'
|
import { trackMouseInit } from './desktop'
|
||||||
import { thresholdCtlInit } from './thresholdCtl'
|
import { thresholdCtlInit } from './thresholdCtl'
|
||||||
@@ -7,6 +8,7 @@ import { preloader } from './imageCache'
|
|||||||
import { getDeviceType } from './utils'
|
import { getDeviceType } from './utils'
|
||||||
|
|
||||||
const desktopInit = (): void => {
|
const desktopInit = (): void => {
|
||||||
|
createDesktopElements()
|
||||||
preloader(0)
|
preloader(0)
|
||||||
vwRefreshInit()
|
vwRefreshInit()
|
||||||
imgIndexSpanUpdate(0, imagesArrayLen)
|
imgIndexSpanUpdate(0, imagesArrayLen)
|
||||||
|
|||||||
@@ -7,7 +7,6 @@ import {
|
|||||||
mouseToTransform
|
mouseToTransform
|
||||||
} from './utils'
|
} from './utils'
|
||||||
import {
|
import {
|
||||||
layers,
|
|
||||||
handleOnMove,
|
handleOnMove,
|
||||||
globalIndex,
|
globalIndex,
|
||||||
globalIndexDec,
|
globalIndexDec,
|
||||||
@@ -16,18 +15,11 @@ import {
|
|||||||
} from './desktop'
|
} from './desktop'
|
||||||
import { imagesArray, imagesArrayLen } from './dataFetch'
|
import { imagesArray, imagesArrayLen } from './dataFetch'
|
||||||
import { imgIndexSpanUpdate } from './indexDisp'
|
import { imgIndexSpanUpdate } from './indexDisp'
|
||||||
|
import { overlayCursor, cursorInnerContent, layers } from './elemGen'
|
||||||
// get components of overlay
|
|
||||||
const overlayCursor = document
|
|
||||||
.getElementsByClassName('overlay_cursor')
|
|
||||||
.item(0) as HTMLDivElement
|
|
||||||
const innerContent = document
|
|
||||||
.getElementsByClassName('cursor_innerText')
|
|
||||||
.item(0) as HTMLDivElement
|
|
||||||
|
|
||||||
// set cursor text
|
// set cursor text
|
||||||
const setCursorText = (text: string): void => {
|
const setCursorText = (text: string): void => {
|
||||||
innerContent.innerText = text
|
cursorInnerContent.innerText = text
|
||||||
}
|
}
|
||||||
|
|
||||||
// overlay cursor event handler
|
// overlay cursor event handler
|
||||||
|
|||||||
@@ -35,7 +35,6 @@
|
|||||||
{{ end }}
|
{{ end }}
|
||||||
<script id="images_array" type="application/json">{{ $.Scratch.Get "img" | jsonify | safeJS }}</script>
|
<script id="images_array" type="application/json">{{ $.Scratch.Get "img" | jsonify | safeJS }}</script>
|
||||||
{{ end }}
|
{{ end }}
|
||||||
{{ partial "desktop_wrapper.html" . }}
|
|
||||||
</div>
|
</div>
|
||||||
<footer>
|
<footer>
|
||||||
{{ partial "footer.html" . }}
|
{{ partial "footer.html" . }}
|
||||||
|
|||||||
@@ -1,19 +0,0 @@
|
|||||||
<div class='desktopWrapper'>
|
|
||||||
{{ partial "overlay.html" . }}
|
|
||||||
<!-- <div class='images'></div>-->
|
|
||||||
<div class="image_container" id="layer15" data-status="null"></div>
|
|
||||||
<div class="image_container" id="layer14" data-status="null"></div>
|
|
||||||
<div class="image_container" id="layer13" data-status="null"></div>
|
|
||||||
<div class="image_container" id="layer12" data-status="null"></div>
|
|
||||||
<div class="image_container" id="layer11" data-status="null"></div>
|
|
||||||
<div class="image_container" id="layer10" data-status="null"></div>
|
|
||||||
<div class="image_container" id="layer9" data-status="null"></div>
|
|
||||||
<div class="image_container" id="layer8" data-status="null"></div>
|
|
||||||
<div class="image_container" id="layer7" data-status="null"></div>
|
|
||||||
<div class="image_container" id="layer6" data-status="null"></div>
|
|
||||||
<div class="image_container" id="layer5" data-status="null"></div>
|
|
||||||
<div class="image_container" id="layer4" data-status="null"></div>
|
|
||||||
<div class="image_container" id="layer3" data-status="null"></div>
|
|
||||||
<div class="image_container" id="layer2" data-status="null"></div>
|
|
||||||
<div class="image_container" id="layer1" data-status="null"></div>
|
|
||||||
</div>
|
|
||||||
@@ -1,3 +0,0 @@
|
|||||||
<div class="overlay_cursor" data-status='null'>
|
|
||||||
<div class="cursor_innerText"></div>
|
|
||||||
</div>
|
|
||||||
Reference in New Issue
Block a user