Added custom tab pages animations

This commit is contained in:
Stefan Zermatten
2017-01-27 15:34:09 +02:00
parent d710579025
commit 3530eefb2a
12 changed files with 185 additions and 43 deletions

View File

@@ -13,7 +13,7 @@
"disallowMixedSpacesAndTabs": "smart", "disallowMixedSpacesAndTabs": "smart",
"disallowTrailingWhitespace": true, "disallowTrailingWhitespace": true,
"disallowSpaceAfterPrefixUnaryOperators": true, "disallowSpaceAfterPrefixUnaryOperators": true,
"disallowMultipleVarDecl": true, "disallowMultipleVarDecl": false,
"disallowNewlineBeforeBlockStatements": true, "disallowNewlineBeforeBlockStatements": true,
"disallowKeywordsOnNewLine": ["else"], "disallowKeywordsOnNewLine": ["else"],

View File

@@ -44,3 +44,5 @@ shell-server
seba:minifiers-autoprefixer seba:minifiers-autoprefixer
nikogosovd:multiple-uihooks nikogosovd:multiple-uihooks
templates:array templates:array
ecmascript
es5-shim

View File

@@ -40,6 +40,7 @@ ecmascript-runtime@0.3.15
ecwyne:mathjs@0.25.0 ecwyne:mathjs@0.25.0
ejson@1.0.13 ejson@1.0.13
email@1.1.18 email@1.1.18
es5-shim@4.6.15
fastclick@1.0.13 fastclick@1.0.13
geojson-utils@1.0.10 geojson-utils@1.0.10
google@1.1.15 google@1.1.15

View File

@@ -56,7 +56,8 @@ paper-icon-item::shadow #contentIcon {
bottom: 24px; bottom: 24px;
right: 24px; right: 24px;
/* stop the fab from flashing during animation */ /* stop the fab from flashing during animation */
transform: translateZ(0); transform: scale(1) translateZ(0px);
z-index: 3;
} }
paper-fab { paper-fab {

View File

@@ -1,28 +1,3 @@
paper-tabs {
box-shadow: 0px 3px 2px rgba(0, 0, 0, 0.2);
}
app-toolbar paper-tabs {
box-shadow: none;
}
paper-tabs[noink][nobar] paper-tab.core-selected {
color: #fff;
}
paper-tabs /deep/ #selectionBar, #onRadio {
background-color: #d50000;
}
paper-tabs ::shadow #ink {
color: #b22 !important;
}
paper-tabs.transparent-brown {
background-color: transparent;
box-shadow: none;
}
app-toolbar.medium-tall { app-toolbar.medium-tall {
height: 108px; height: 108px;
} }
@@ -37,3 +12,13 @@ app-toolbar.medium-tall {
.character-menu paper-icon-item{ .character-menu paper-icon-item{
cursor: pointer; cursor: pointer;
} }
.character-sheet app-header {
position: relative;
z-index: 1;
}
.character-sheet iron-pages > div {
overflow-y: auto;
overflow-x: hidden;
}

View File

@@ -1,6 +1,6 @@
<template name="characterSheet"> <template name="characterSheet">
<app-header-layout has-scrolling-region fullbleed> <div class="fit layout vertical character-sheet">
<app-header fixed> <app-header fixed effects="waterfall">
<app-toolbar class="medium-tall {{colorClass}}"> <app-toolbar class="medium-tall {{colorClass}}">
<div top-item class="layout horizontal center"> <div top-item class="layout horizontal center">
<paper-icon-button icon="menu" drawer-toggle></paper-icon-button> <paper-icon-button icon="menu" drawer-toggle></paper-icon-button>
@@ -42,17 +42,17 @@
</div> </div>
</app-toolbar> </app-toolbar>
</app-header> </app-header>
<div> <div class="flex" style="position: relative;">
<neon-animated-pages id="tabPages" selected={{selectedTab}}> <iron-pages id="tabPages" class="fit" selected={{selectedTab}}>
<div name="stats">{{> stats}}</div> <div name="stats" class="tab-page fit">{{> stats}}</div>
<div name="features">{{> features}}</div> <div name="features" class="tab-page fit">{{> features}}</div>
<div name="inventory">{{> inventory}}</div> <div name="inventory" class="tab-page fit">{{> inventory}}</div>
{{#unless hideSpellcasting}} {{#unless hideSpellcasting}}
<div name="spells">{{> spells}}</div> <div name="spells" class="tab-page fit">{{> spells}}</div>
{{/unless}} {{/unless}}
<div name="persona">{{> persona}}</div> <div name="persona" class="tab-page fit">{{> persona}}</div>
<div name="journal">{{> journal}}</div> <div name="journal" class="tab-page fit">{{> journal}}</div>
</neon-animated-pages> </iron-pages>
</div> </div>
</app-header-layout> </div>
</template> </template>

View File

@@ -1,11 +1,158 @@
let tabPages, tabSliders, tabFabs, tabFabMenus;
Template.characterSheet.onRendered(function() { Template.characterSheet.onRendered(function() {
//default to the stats tab //default to the stats tab
Session.setDefault(this.data._id + ".selectedTab", "0"); Session.setDefault(this.data._id + ".selectedTab", "0");
// Keep the header's scroll target up to date with the currently selected tab
const header = this.find("app-header");
this.autorun(() => {
const tab = getTab(Template.currentData()._id);
Tracker.afterFlush(() => {
header.scrollTarget = this.find("#tabPages .iron-selected");
header._scrollHandler();
});
});
// Store all the tab page components for use in animations
tabPages = _.times(6, (n) =>
this.$(`.tab-page:nth-child(${n + 1})`)
);
tabSliders = _.times(6, (n) =>
tabPages[n].find(".animation-slider")
);
tabFabs = _.times(6, (n) =>
tabPages[n].find(".floatyButton")
);
tabFabMenus = _.times(6, (n) =>
tabPages[n].find(".mini-holder")
);
//watch this character and make sure their encumbrance is updated //watch this character and make sure their encumbrance is updated
//trackEncumbranceConditions(this.data._id, this); //trackEncumbranceConditions(this.data._id, this);
}); });
/**
* Page change animations that suck less than neon-animated-pages
*/
const tabAnimation = ({oldTab, newTab, duration}) => {
if (newTab === oldTab) return;
duration = duration || 400;
const delay = (element, f) => {
element.on(
"transitionend webkitTransitionEnd oTransitionEnd MSTransitionEnd",
(event) => {
if (event.target == event.currentTarget){
f();
$(this).off(event);
}
}
);
}
const isForward = newTab > oldTab;
const entryAnimation = {
before: {
transform: isForward ? "translateX(100%)" : "translateX(-100%)",
},
during: {
transition: `transform ${duration}ms ease`,
transform: "",
},
after: {
transition: "",
transform: "",
},
}
const exitAnimation = {
before: {
transform: "translateZ(0)",
},
during: {
transition: `transform ${duration}ms ease`,
transform: isForward ? "translateX(-100%)" : "translateX(100%)",
},
after: {
transition: "",
transform: "",
display: "",
},
}
const oldPage = tabPages[oldTab];
const newPage = tabPages[newTab];
if (oldPage.length && newPage.length){
oldPage[0].style.setProperty("display", "initial", "important");
oldPage.css({zIndex: "1"});
newPage.css({zIndex: "0"});
_.defer(() => {
oldPage.css({
transition: `z-index ${duration}ms linear`,
zIndex: "0",
});
newPage.css({
transition: `z-index ${duration}ms linear`,
zIndex: "1",
});
});
delay(oldPage, () => oldPage.css({
display: "",
transition: "",
zIndex: "",
}));
delay(newPage, () => newPage.css({
transition: "",
zIndex: "",
}));
}
const oldSlider = tabSliders[oldTab];
if (oldSlider.length){
oldSlider.css(exitAnimation.before);
_.defer(() => oldSlider.css(exitAnimation.during));
delay(oldSlider, () => oldSlider.css(exitAnimation.after));
}
const newSlider = tabSliders[newTab];
if (newSlider.length){
newSlider.css(entryAnimation.before);
_.defer(() => newSlider.css(entryAnimation.during));
delay(newSlider, () => newSlider.css(entryAnimation.after));
}
slideDown = ({element, reverse}) => {
element.css({
transform: reverse ? "translateY(80px)" : "",
});
const fraction = duration / 4;
_.defer(() => element.css({
transition: reverse ?
`transform ${fraction}ms ease-out ${duration - fraction}ms` :
`transform ${fraction}ms ease-in`,
transform: reverse ? "" : "translateY(80px)",
}));
delay(element, () => element.css({
transition: "",
}));
}
const oldFab = tabFabs[oldTab];
const newFab = tabFabs[newTab];
if (oldFab.length && !newFab.length){
slideDown({element: oldFab});
}
if (newFab.length && !oldFab.length){
slideDown({element: newFab, reverse: true});
}
if (newFab.length && oldFab.length){
newFab.css({transform: ""});
}
const oldFabMenu = tabFabMenus[oldTab];
if (oldFabMenu.length) {
Blaze.getView(oldFabMenu[0]).templateInstance().active.set(false);
}
}
var setTab = function(charId, tab){ var setTab = function(charId, tab){
tabAnimation({
oldTab: +Session.get(charId + ".selectedTab"),
newTab: +tab,
});
return Session.set(charId + ".selectedTab", tab); return Session.set(charId + ".selectedTab", tab);
}; };

View File

@@ -1,6 +1,6 @@
<template name="features"> <template name="features">
<div class="features"> <div class="features">
<div class="column-container"> <div class="column-container animation-slider">
<!--expertiseDice--> <!--expertiseDice-->
{{>resource name="expertiseDice" title="Expertise Dice" color="teal" char=this}} {{>resource name="expertiseDice" title="Expertise Dice" color="teal" char=this}}
<!--ki--> <!--ki-->

View File

@@ -1,5 +1,5 @@
<template name="inventory"> <template name="inventory">
<div id="inventory"> <div id="inventory" class="animation-slider">
<div class="column-container"> <div class="column-container">
<!--Net Worth--> <!--Net Worth-->
<div> <div>

View File

@@ -1,5 +1,5 @@
<template name="stats"> <template name="stats">
<div class="stats"> <div class="stats animation-slider">
<div style="padding: 8px 8px 0 8px"> <div style="padding: 8px 8px 0 8px">
{{> healthCard}} {{> healthCard}}
</div> </div>

View File

@@ -24,10 +24,10 @@
<!--<link rel="import" href="/components/iron-icons/places-icons.html">--> <!--<link rel="import" href="/components/iron-icons/places-icons.html">-->
<link rel="import" href="/components/iron-icons/social-icons.html"> <link rel="import" href="/components/iron-icons/social-icons.html">
<link rel="import" href="/components/iron-image/iron-image.html"> <link rel="import" href="/components/iron-image/iron-image.html">
<link rel="import" href="/components/iron-pages/iron-pages.html">
<link rel="import" href="/components/iron-selector/iron-selector.html"> <link rel="import" href="/components/iron-selector/iron-selector.html">
<link rel="import" href="/components/neon-animation/neon-animation.html"> <link rel="import" href="/components/neon-animation/neon-animation.html">
<link rel="import" href="/components/neon-animation/neon-animations.html">
<link rel="import" href="/components/paper-button/paper-button.html"> <link rel="import" href="/components/paper-button/paper-button.html">
<!--<link rel="import" href="/components/paper-checkbox/paper-checkbox.html"> Using custom one instead --> <!--<link rel="import" href="/components/paper-checkbox/paper-checkbox.html"> Using custom one instead -->

View File

@@ -21,6 +21,12 @@
color: #dedede; color: #dedede;
color: rgba(255,255,255,0.87); color: rgba(255,255,255,0.87);
} }
paper-tabs {
--paper-tabs-selection-bar-color: var(--accent-color);
}
paper-tab {
--paper-tab-ink: var(--light-accent-color);
}
a { a {
color: inherit; color: inherit;
text-decoration: none; text-decoration: none;