Skip to content

Commit

Permalink
perf: use current date for placeholder id as well
Browse files Browse the repository at this point in the history
  • Loading branch information
johannschopplich committed Nov 12, 2024
1 parent 821bfe8 commit b8f9595
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion packages/core/src/constants.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
export const DEFAULT_PLACEHOLDER_SIZE = 32
export const DEFAULT_IMAGE_PLACEHOLDER = `data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 1 1' data-i=''%3E%3C/svg%3E`
export const DEFAULT_IMAGE_PLACEHOLDER = `data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 1 1' data-id=''%3E%3C/svg%3E`
3 changes: 2 additions & 1 deletion packages/core/src/utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ export function toElementArray<T extends HTMLElement>(
}

export function createIndexedImagePlaceholder(index: number) {
return DEFAULT_IMAGE_PLACEHOLDER.replace('data-i=\'\'', `data-i='${index}'`)
const now = Date.now()
return DEFAULT_IMAGE_PLACEHOLDER.replace('data-id=\'\'', `data-id='${now}-${index}'`)
}

export function calculateAspectRatioDimensions(aspectRatio: number, referenceSize: number) {
Expand Down

0 comments on commit b8f9595

Please sign in to comment.