Skip to content

Instantly share code, notes, and snippets.

@ManotLuijiu
Created February 21, 2021 04:28
Show Gist options
  • Save ManotLuijiu/47b88e0fbf31b80edd0aaeb87c2a83a0 to your computer and use it in GitHub Desktop.
Save ManotLuijiu/47b88e0fbf31b80edd0aaeb87c2a83a0 to your computer and use it in GitHub Desktop.
Get elements then inject opacity from 0 to 1
document.addEventListener('DOMContentLoaded', () => {
var myOpacity = 0;
var readMeter = document.getElementsByClassName('bsf-rt-display-label')[0];
var readUnit = document.getElementsByClassName('bsf-rt-display-postfix')[0];
var readColor = document.getElementsByClassName('bsf-rt-reading-time')[0];
function MyFadeFunction() {
if (myOpacity < 1) {
myOpacity += 0.075;
setTimeout(function () {
MyFadeFunction();
}, 1000);
}
document.getElementById('means__read__meter').style.opacity = myOpacity;
readMeter.setAttribute('prefix', 'ใช้เวลาอ่าน');
readUnit.setAttribute('postfix', 'นาที');
readColor.setAttribute('style', 'color: #0984e3;');
}
MyFadeFunction();
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment