Add appbar fade on focus view.
This commit is contained in:
parent
89b3159c12
commit
3d66205755
@ -9,7 +9,7 @@ import { CLICKABLE } from '../styles.js';
|
|||||||
let seq = 0;
|
let seq = 0;
|
||||||
|
|
||||||
export function AppBarView(vm, params, key, opts) {
|
export function AppBarView(vm, params, key, opts) {
|
||||||
const stateStack = container([], arr => arr.length);
|
const stateStack = container([], arr => arr.length && arr[0]._seq);
|
||||||
const companionScrollTop = prop(0);
|
const companionScrollTop = prop(0);
|
||||||
|
|
||||||
const currentState = computed(stack => stack[0] || {}, [stateStack]);
|
const currentState = computed(stack => stack[0] || {}, [stateStack]);
|
||||||
@ -51,9 +51,16 @@ export function AppBarView(vm, params, key, opts) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function replaceState(newState) {
|
||||||
|
companionScrollTop(0);
|
||||||
|
stateStack._.shift();
|
||||||
|
stateStack.unshift(Object.assign({ _seq: seq++ }, newState));
|
||||||
|
}
|
||||||
|
|
||||||
opts.appbar = {
|
opts.appbar = {
|
||||||
pushState,
|
pushState,
|
||||||
popState,
|
popState,
|
||||||
|
replaceState,
|
||||||
companionScrollTop
|
companionScrollTop
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -88,7 +95,8 @@ const appBarContainer = styled({
|
|||||||
zIndex: 1000,
|
zIndex: 1000,
|
||||||
display: 'flex',
|
display: 'flex',
|
||||||
alignItems: 'center',
|
alignItems: 'center',
|
||||||
width: '100%'
|
width: '100%',
|
||||||
|
transition: 'opacity .13s cubic-bezier(0.0,0.0,0.2,1)'
|
||||||
});
|
});
|
||||||
|
|
||||||
const upButtonContainer = styled(
|
const upButtonContainer = styled(
|
||||||
|
|||||||
@ -25,6 +25,8 @@ export function FocusView(vm, params, key, { appbar, appbarView }) {
|
|||||||
const { body } = document;
|
const { body } = document;
|
||||||
const nextLink = prop();
|
const nextLink = prop();
|
||||||
const prevLink = prop();
|
const prevLink = prop();
|
||||||
|
const mouseActive = prop(true);
|
||||||
|
let mouseMoveTimeout = null;
|
||||||
|
|
||||||
const imageStyle = computed(
|
const imageStyle = computed(
|
||||||
({ width: iw, height: ih }, { width: vw, height: vh }) => {
|
({ width: iw, height: ih }, { width: vw, height: vh }) => {
|
||||||
@ -49,6 +51,17 @@ export function FocusView(vm, params, key, { appbar, appbarView }) {
|
|||||||
},
|
},
|
||||||
[doc, fullViewportSize]
|
[doc, fullViewportSize]
|
||||||
);
|
);
|
||||||
|
const appbarState = computed(
|
||||||
|
mA => ({
|
||||||
|
title: '',
|
||||||
|
actions: renderAppBarButtons,
|
||||||
|
style: { position: 'fixed', opacity: mA ? 1 : 0 },
|
||||||
|
up: {
|
||||||
|
navigateTo: 'home'
|
||||||
|
}
|
||||||
|
}),
|
||||||
|
[mouseActive]
|
||||||
|
);
|
||||||
|
|
||||||
function navBack() {
|
function navBack() {
|
||||||
appbar.popState('home');
|
appbar.popState('home');
|
||||||
@ -61,6 +74,25 @@ export function FocusView(vm, params, key, { appbar, appbarView }) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const mouseLeave = () => {
|
||||||
|
mouseActive(false);
|
||||||
|
};
|
||||||
|
|
||||||
|
const mouseMove = () => {
|
||||||
|
if (mouseMoveTimeout !== null) {
|
||||||
|
clearTimeout(mouseMoveTimeout);
|
||||||
|
}
|
||||||
|
mouseMoveTimeout = setTimeout(mouseLeave, 3000);
|
||||||
|
mouseActive(true);
|
||||||
|
};
|
||||||
|
|
||||||
|
const mouseClick = () => {
|
||||||
|
if (mouseMoveTimeout !== null) {
|
||||||
|
clearTimeout(mouseMoveTimeout);
|
||||||
|
}
|
||||||
|
mouseActive(!mouseActive());
|
||||||
|
};
|
||||||
|
|
||||||
function renderAppBarButtons() {
|
function renderAppBarButtons() {
|
||||||
return [
|
return [
|
||||||
trashButtonContainer(
|
trashButtonContainer(
|
||||||
@ -78,10 +110,13 @@ export function FocusView(vm, params, key, { appbar, appbarView }) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Set the appbar title.
|
// Set the appbar title.
|
||||||
|
|
||||||
appbar.pushState({
|
appbar.pushState({
|
||||||
title: '',
|
title: '',
|
||||||
actions: renderAppBarButtons,
|
actions: renderAppBarButtons,
|
||||||
style: { position: 'fixed' },
|
style: {
|
||||||
|
position: 'fixed'
|
||||||
|
},
|
||||||
up: {
|
up: {
|
||||||
navigateTo: 'home'
|
navigateTo: 'home'
|
||||||
}
|
}
|
||||||
@ -94,6 +129,7 @@ export function FocusView(vm, params, key, { appbar, appbarView }) {
|
|||||||
doc,
|
doc,
|
||||||
nextLink,
|
nextLink,
|
||||||
prevLink,
|
prevLink,
|
||||||
|
() => appbarState.subscribe(appbar.replaceState),
|
||||||
// Look for our image and set it.
|
// Look for our image and set it.
|
||||||
() =>
|
() =>
|
||||||
id.subscribe(async _id => {
|
id.subscribe(async _id => {
|
||||||
@ -128,7 +164,14 @@ export function FocusView(vm, params, key, { appbar, appbarView }) {
|
|||||||
return Overlay('Loading...');
|
return Overlay('Loading...');
|
||||||
}
|
}
|
||||||
|
|
||||||
return focusContainer({ class: 'focus' }, [
|
return focusContainer(
|
||||||
|
{
|
||||||
|
class: 'focus',
|
||||||
|
onmousemove: mouseMove,
|
||||||
|
onmouseleave: mouseLeave,
|
||||||
|
onclick: mouseClick
|
||||||
|
},
|
||||||
|
[
|
||||||
iv(appbarView),
|
iv(appbarView),
|
||||||
focusContent([
|
focusContent([
|
||||||
prevLink()
|
prevLink()
|
||||||
@ -152,7 +195,8 @@ export function FocusView(vm, params, key, { appbar, appbarView }) {
|
|||||||
])
|
])
|
||||||
: null
|
: null
|
||||||
])
|
])
|
||||||
]);
|
]
|
||||||
|
);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user