Skip to content

Commit

Permalink
Update Color Transform script
Browse files Browse the repository at this point in the history
  • Loading branch information
sonvnn committed Sep 9, 2024
1 parent 2837c4d commit c2db64a
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 10 deletions.
22 changes: 13 additions & 9 deletions js/colortransform.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,22 @@
(function ($) {
function colorTransform () {
if ((window.innerHeight + window.scrollY) >= document.body.scrollHeight * (ASTROID_COLOR_TRANSFORM.offset/100)) {
if ($('html').attr('data-bs-theme') === ASTROID_COLOR_TRANSFORM.from) {
$('html').attr('data-bs-theme', ASTROID_COLOR_TRANSFORM.to);
}
} else {
if ($('html').attr('data-bs-theme') === ASTROID_COLOR_TRANSFORM.to) {
$('html').attr('data-bs-theme', ASTROID_COLOR_TRANSFORM.from);
}
}
}
$(document).ready(function (){
$('body').addClass('as-transition-body');
colorTransform();
})
$(window).on('load', function () {
window.onscroll = function(ev) {
if ((window.innerHeight + window.scrollY) >= document.body.scrollHeight * (ASTROID_COLOR_TRANSFORM.offset/100)) {
if ($('html').attr('data-bs-theme') === ASTROID_COLOR_TRANSFORM.from) {
$('html').attr('data-bs-theme', ASTROID_COLOR_TRANSFORM.to);
}
} else {
if ($('html').attr('data-bs-theme') === ASTROID_COLOR_TRANSFORM.to) {
$('html').attr('data-bs-theme', ASTROID_COLOR_TRANSFORM.from);
}
}
colorTransform();
};
})
}(jQuery));
2 changes: 1 addition & 1 deletion js/colortransform.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit c2db64a

Please sign in to comment.