add overscroll unblur controls

This commit is contained in:
Kuldeep M 2021-12-05 23:24:44 +00:00 committed by GitHub
parent 45141b4a1c
commit f9183a47db
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 136 additions and 30 deletions

2
package-lock.json generated
View File

@ -1,6 +1,6 @@
{ {
"name": "nightTab", "name": "nightTab",
"version": "7.3.0", "version": "7.4.0",
"lockfileVersion": 2, "lockfileVersion": 2,
"requires": true, "requires": true,
"packages": { "packages": {

View File

@ -1,6 +1,6 @@
{ {
"name": "nightTab", "name": "nightTab",
"version": "7.3.0", "version": "7.4.0",
"description": "A neutral new tab page accented with a chosen colour. Customise the layout, style, background and bookmarks with nightTab.", "description": "A neutral new tab page accented with a chosen colour. Customise the layout, style, background and bookmarks with nightTab.",
"main": "index.js", "main": "index.js",
"scripts": { "scripts": {

View File

@ -7,6 +7,10 @@
--layout-line-width: 0.25em; --layout-line-width: 0.25em;
} }
:root {
--layout-overscroll: 75;
}
:root { :root {
--layout-duration-01: 0.1s; --layout-duration-01: 0.1s;
--layout-duration-02: 0.2s; --layout-duration-02: 0.2s;
@ -188,8 +192,8 @@
margin-right: calc((var(--layout-space) * var(--layout-padding)) * -1); margin-right: calc((var(--layout-space) * var(--layout-padding)) * -1);
} }
.is-layout-overscroll body { .is-layout-overscroll-active body {
margin-bottom: 75vh; margin-bottom: calc(var(--layout-overscroll) * 1vh);
} }
html.is-layout-scrollbar-auto, html.is-layout-scrollbar-auto,

View File

@ -34,7 +34,7 @@ layout.area = {
let breakpoint; let breakpoint;
entries.forEach(function (entry) { entries.forEach(function(entry) {
if (entry.contentRect.width <= size.sm) { if (entry.contentRect.width <= size.sm) {
breakpoint = 'xs'; breakpoint = 'xs';
@ -174,6 +174,60 @@ layout.breakpoint = {
} }
}; };
layout.overscroll = {
bind: () => {
if (state.get.current().layout.overscroll.unblur) {
window.addEventListener('scroll', layout.overscroll.unblur);
} else {
window.removeEventListener('scroll', layout.overscroll.unblur);
}
},
unblur: () => {
const html = document.querySelector('html');
const body = document.querySelector('body');
const overscrollHeight = parseInt(window.innerHeight * (parseFloat(getComputedStyle(html).getPropertyValue('--layout-overscroll'), 10) / 100), 10);
const bottomOfBody = (window.scrollY + window.innerHeight) - body.offsetHeight; // height of body not including the margin when scroll past end is true
if (body.offsetHeight < (window.scrollY + window.innerHeight)) {
switch (state.get.current().theme.background.type) {
case 'image':
html.style.setProperty('--theme-background-image-blur', parseInt(state.get.current().theme.background.image.blur - ((parseInt(((bottomOfBody) / overscrollHeight) * 100, 10) / 100) * state.get.current().theme.background.image.blur), 10));
break;
case 'video':
html.style.setProperty('--theme-background-video-blur', parseInt(state.get.current().theme.background.video.blur - ((parseInt(((bottomOfBody) / overscrollHeight) * 100, 10) / 100) * state.get.current().theme.background.video.blur), 10));
break;
}
} else {
applyCSSVar([
'theme.background.image.blur',
'theme.background.video.blur'
]);
}
}
};
layout.title = { layout.title = {
render: () => { render: () => {
@ -228,11 +282,12 @@ layout.init = () => {
'layout.scrollbar' 'layout.scrollbar'
]); ]);
applyCSSState([ applyCSSState([
'layout.overscroll' 'layout.overscroll.active'
]); ]);
layout.area.render(); layout.area.render();
layout.title.render(); layout.title.render();
layout.favicon.render(); layout.favicon.render();
layout.overscroll.bind();
}; };
export { layout }; export { layout };

View File

@ -3,6 +3,7 @@ import { data } from '../../data';
import { header } from '../../header'; import { header } from '../../header';
import { bookmark } from '../../bookmark'; import { bookmark } from '../../bookmark';
import { layout } from '../../layout'; import { layout } from '../../layout';
import { theme } from '../../theme';
import * as form from '../../form'; import * as form from '../../form';
@ -84,6 +85,12 @@ layoutSetting.disable = () => {
} }
if (state.get.current().layout.overscroll.active) {
layoutSetting.control.page.overscroll.unblur.enable();
} else {
layoutSetting.control.page.overscroll.unblur.disable();
}
}; };
layoutSetting.edge = { layoutSetting.edge = {
@ -467,16 +474,36 @@ layoutSetting.page = (parent) => {
text: ['Not supported by all browsers.'] text: ['Not supported by all browsers.']
}); });
layoutSetting.control.page.overscroll = new Control_checkbox({ layoutSetting.control.page.overscroll = {
active: new Control_checkbox({
object: state.get.current(), object: state.get.current(),
path: 'layout.overscroll', path: 'layout.overscroll.active',
id: 'layout-overscroll', id: 'layout-overscroll-active',
labelText: 'Scroll past end', labelText: 'Scroll past end',
action: () => { action: () => {
applyCSSState('layout.overscroll'); applyCSSState('layout.overscroll.active');
layoutSetting.disable();
data.save(); data.save();
} }
}); }),
unblur: new Control_checkbox({
object: state.get.current(),
path: 'layout.overscroll.unblur',
id: 'layout-overscroll-unblur-background',
labelText: 'Unblur background image or video',
description: [
'Background image or video will unblur when scrolled to the bottom of the page.',
'Image or video blur can be found under Theme Background.'
],
action: () => {
theme.background.image.render();
theme.background.video.clear();
theme.background.video.render();
layout.overscroll.bind();
data.save();
}
})
};
parent.appendChild( parent.appendChild(
node('div', [ node('div', [
@ -487,7 +514,16 @@ layoutSetting.page = (parent) => {
layoutSetting.control.page.scrollbar.inline(), layoutSetting.control.page.scrollbar.inline(),
layoutSetting.control.page.scrollbarHelper.wrap(), layoutSetting.control.page.scrollbarHelper.wrap(),
node('hr'), node('hr'),
layoutSetting.control.page.overscroll.wrap() layoutSetting.control.page.overscroll.active.wrap(),
form.wrap({
children: [
form.indent({
children: [
layoutSetting.control.page.overscroll.unblur.wrap()
]
})
]
})
]) ])
); );

View File

@ -19,7 +19,7 @@ state.default = {
scrollbar: 'auto', scrollbar: 'auto',
title: '', title: '',
favicon: '', favicon: '',
overscroll: false overscroll: { active: false, unblur: false }
}, },
header: { header: {
item: { justify: 'left' }, item: { justify: 'left' },

View File

@ -345,11 +345,11 @@
width: 100%; width: 100%;
height: 100%; height: 100%;
z-index: 1; z-index: 1;
opacity: calc(var(--theme-background-image-opacity) / 100);
background-image: var(--theme-background-image); background-image: var(--theme-background-image);
background-attachment: fixed; background-attachment: fixed;
background-size: cover; background-size: cover;
background-position: center; background-position: center;
opacity: calc(var(--theme-background-image-opacity) / 100);
transform: scale(calc(calc(var(--theme-background-image-scale) / 100) + calc(var(--theme-background-image-blur) / 400))); transform: scale(calc(calc(var(--theme-background-image-scale) / 100) + calc(var(--theme-background-image-blur) / 400)));
filter: blur(calc(var(--theme-background-image-blur) * 1px)) grayscale(calc(var(--theme-background-image-grayscale) / 100)); filter: blur(calc(var(--theme-background-image-blur) * 1px)) grayscale(calc(var(--theme-background-image-grayscale) / 100));
} }
@ -385,8 +385,8 @@
height: 100%; height: 100%;
z-index: 1; z-index: 1;
opacity: calc(var(--theme-background-video-opacity) / 100); opacity: calc(var(--theme-background-video-opacity) / 100);
transform: scale(calc(calc(var(--theme-background-video-scale) / 100) + calc(var(--theme-background-video-blur) / 400)));
filter: blur(calc(var(--theme-background-video-blur) * 1px)) grayscale(calc(var(--theme-background-video-grayscale) / 100)); filter: blur(calc(var(--theme-background-video-blur) * 1px)) grayscale(calc(var(--theme-background-video-grayscale) / 100));
transform: scale(calc(var(--theme-background-video-scale) / 100));
} }
.theme-background-type-video-accent { .theme-background-type-video-accent {

View File

@ -1,5 +1,6 @@
import { state } from '../state'; import { state } from '../state';
import { APP_NAME } from '../../constant'; import { APP_NAME } from '../../constant';
import { layout } from '../layout';
import { toolbar } from '../toolbar'; import { toolbar } from '../toolbar';
import { bookmark } from '../bookmark'; import { bookmark } from '../bookmark';
import { bookmarkDefault } from '../bookmarkDefault'; import { bookmarkDefault } from '../bookmarkDefault';

View File

@ -6,7 +6,7 @@ const update = {};
update.mod = updateLegacy.get(); update.mod = updateLegacy.get();
update.mod['7.0.0'] = function (data) { update.mod['7.0.0'] = function(data) {
data.state.header.order.splice(data.state.header.order.indexOf('editAdd'), 1); data.state.header.order.splice(data.state.header.order.indexOf('editAdd'), 1);
data.state.header.order.splice(data.state.header.order.indexOf('colorAccent'), 1); data.state.header.order.splice(data.state.header.order.indexOf('colorAccent'), 1);
@ -572,7 +572,7 @@ update.mod['7.0.0'] = function (data) {
return data; return data;
}; };
update.mod['7.1.0'] = function (data) { update.mod['7.1.0'] = function(data) {
data.state.layout.favicon = ''; data.state.layout.favicon = '';
@ -606,6 +606,16 @@ update.mod['7.1.0'] = function (data) {
return data; return data;
}; };
update.mod['7.4.0'] = function(data) {
data.state.layout.overscroll = {
active: data.state.layout.overscroll,
unblur: false
};
return data;
};
update.run = (data) => { update.run = (data) => {
// loop over all updates in mod.all object // loop over all updates in mod.all object

View File

@ -1,6 +1,6 @@
export const version = {}; export const version = {};
version.number = '7.3.0'; version.number = '7.4.0';
version.name = 'Delightful Komodo Dragon'; version.name = 'Delightful Komodo Dragon';

View File

@ -2,7 +2,7 @@
"name": "nightTab", "name": "nightTab",
"short_name": "nightTab", "short_name": "nightTab",
"description": "A neutral new tab page accented with a chosen colour. Customise the layout, style, background and bookmarks in nightTab.", "description": "A neutral new tab page accented with a chosen colour. Customise the layout, style, background and bookmarks in nightTab.",
"version": "7.3.0", "version": "7.4.0",
"manifest_version": 2, "manifest_version": 2,
"chrome_url_overrides": { "chrome_url_overrides": {
"newtab": "index.html" "newtab": "index.html"