mirror of
https://github.com/Sped0n/bridget.git
synced 2026-04-22 14:09:30 -07:00
refactor(collection.ts): rename variable 'container' to 'collection' for better clarity and semantics
refactor(collection.ts): update classList manipulation to use 'collection' instead of 'container' for consistency and clarity
This commit is contained in:
@@ -27,19 +27,19 @@ function handleClick(i: number): void {
|
|||||||
export function initCollection(ijs: ImageJSON[]): void {
|
export function initCollection(ijs: ImageJSON[]): void {
|
||||||
createCollection(ijs)
|
createCollection(ijs)
|
||||||
// get container
|
// get container
|
||||||
const container = document
|
const collection = document
|
||||||
.getElementsByClassName('collection')
|
.getElementsByClassName('collection')
|
||||||
.item(0) as HTMLDivElement
|
.item(0) as HTMLDivElement
|
||||||
// add watcher
|
// add watcher
|
||||||
mounted.addWatcher(() => {
|
mounted.addWatcher(() => {
|
||||||
if (mounted.get()) {
|
if (mounted.get()) {
|
||||||
container.classList.remove('hidden')
|
collection.classList.remove('hidden')
|
||||||
} else {
|
} else {
|
||||||
container.classList.add('hidden')
|
collection.classList.add('hidden')
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
// get image elements
|
// get image elements
|
||||||
imgs = Array.from(container.getElementsByTagName('img'))
|
imgs = Array.from(collection.getElementsByTagName('img'))
|
||||||
// add event listeners
|
// add event listeners
|
||||||
imgs.forEach((img, i) => {
|
imgs.forEach((img, i) => {
|
||||||
img.addEventListener('click', () => handleClick(i))
|
img.addEventListener('click', () => handleClick(i))
|
||||||
|
|||||||
Reference in New Issue
Block a user