-
Notifications
You must be signed in to change notification settings - Fork 46
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
https://github.com/bonfire-networks/bonfire-app/issues/792
- Loading branch information
Showing
2 changed files
with
47 additions
and
14 deletions.
There are no files selected for viewing
31 changes: 31 additions & 0 deletions
31
flavours/classic/config/flavour_assets/hooks/Bonfire.UI.Common.LazyImage.hooks.js
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,31 @@ | ||
/* | ||
This file was generated by the Surface compiler. | ||
*/ | ||
|
||
import { decodeBlurHash } from 'fast-blurhash'; | ||
|
||
export default { | ||
mounted() { | ||
// const canvas = document.createElement('canvas'); | ||
const canvas = this.el.getElementsByTagName('canvas')[0]; | ||
console.log(canvas) | ||
const w = canvas.width || 40 | ||
const h = canvas.height || 40 | ||
const default_hash = 'LEHV6nWB2yk8pyo0adR*.7kCMdnj' | ||
const hash = this.el.dataset.hash | ||
console.log(hash) | ||
|
||
// decode blurHash image | ||
const pixels = decodeBlurHash(hash || default_hash, w, h); | ||
console.log(pixels) | ||
|
||
// draw it on canvas | ||
const ctx = canvas.getContext('2d'); | ||
const imageData = ctx.createImageData(w, h); | ||
|
||
imageData.data.set(pixels); | ||
console.log(imageData) | ||
ctx.putImageData(imageData, 0, 0); | ||
// document.body.append(canvas); | ||
} | ||
} |
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