fix toolbar title flickr

This commit is contained in:
Adam Bradley
2015-05-16 22:38:43 -05:00
parent c100bf9604
commit 44a06bea2f
9 changed files with 67 additions and 30 deletions

View File

@ -1,6 +1,14 @@
// Util Mixins/Functions // Util Mixins/Functions
// Appearance (not a CSS standard, does not autoprefix)
// --------------------------------------------------
@mixin appearance($val) {
-webkit-appearance: $val;
-moz-appearance: $val;
}
// String Replace Function // String Replace Function
// -------------------------------------------------- // --------------------------------------------------

View File

@ -95,6 +95,6 @@ $content-padding: 10px !default;
// http://davidwalsh.name/detect-node-insertion // http://davidwalsh.name/detect-node-insertion
@keyframes nodeInserted { @keyframes nodeInserted {
from { opacity: 0.99; } from { transform: scale(0.999); }
to { opacity: 1; } to { transform: scale(1); }
} }

View File

@ -36,7 +36,7 @@ $button-small-icon-size: 2.1rem !default;
margin: $button-margin; margin: $button-margin;
line-height: 1; line-height: 1;
appearance: none; @include appearance(none);
vertical-align: top; // the better option for most scenarios vertical-align: top; // the better option for most scenarios
vertical-align: -webkit-baseline-middle; // the best for those that support it vertical-align: -webkit-baseline-middle; // the best for those that support it

View File

@ -48,7 +48,7 @@ textarea {
input { input {
border-radius: 0; border-radius: 0;
flex: 1 220px; flex: 1 220px;
appearance: none; @include appearance(none);
margin: 0; margin: 0;
padding-right: 24px; padding-right: 24px;
background-color: transparent; background-color: transparent;
@ -66,7 +66,7 @@ textarea {
.button-bar { .button-bar {
border-radius: 0; border-radius: 0;
flex: 1 0 220px; flex: 1 0 220px;
appearance: none; @include appearance(none);
} }
.icon { .icon {

View File

@ -21,7 +21,7 @@ ion-input {
border-radius: 0; border-radius: 0;
flex: 1 220px; flex: 1 220px;
appearance: none; @include appearance(none);
margin: 0; margin: 0;
padding-right: 24px; padding-right: 24px;

View File

@ -26,7 +26,7 @@ $search-bar-min-height: 44px !default;
height: 100%; height: 100%;
border: none; border: none;
font-family: inherit; font-family: inherit;
appearance: none; @include appearance(none);
} }
.search-bar-cancel { .search-bar-cancel {

View File

@ -36,10 +36,10 @@ export class Toolbar {
this.config = Toolbar.config.invoke(this); this.config = Toolbar.config.invoke(this);
// http://davidwalsh.name/detect-node-insertion // http://davidwalsh.name/detect-node-insertion
this.domElement.addEventListener("animationstart", (ev) => { dom.animationStart(this.domElement, 'nodeInserted').then(() => {
ev.stopPropagation();
this.alignTitle(); this.alignTitle();
}); });
} }
alignTitle() { alignTitle() {

View File

@ -51,7 +51,7 @@ ion-title {
display: block; display: block;
// used to notify JS when the title has been rendered // used to notify JS when the title has been rendered
animation-duration: 0.001s; animation-duration: 1ms;
animation-name: nodeInserted; animation-name: nodeInserted;
} }

View File

@ -30,34 +30,63 @@ export function rafPromise() {
export const isSVG = val => window.SVGElement && (val instanceof window.SVGElement); export const isSVG = val => window.SVGElement && (val instanceof window.SVGElement);
// We only need to test for webkit in our supported browsers. Webkit is the only browser still // We only need to test for webkit in our supported browsers. Webkit is the
// using prefixes. // only browser still using prefixes. Code adapted from angular-animate.js
// Code adapted from angular-animate.js export let CSS = {};
export let css = {};
if (window.ontransitionend === undefined && window.onwebkittransitionend !== undefined) { if (window.ontransitionend === undefined && window.onwebkittransitionend !== undefined) {
css.prefix = 'webkit'; CSS.prefix = '-webkit-';
css.transition = 'webkitTransition'; CSS.transition = 'webkitTransition';
css.transform = 'webkitTransform'; CSS.transform = 'webkitTransform';
css.transitionEnd = 'webkitTransitionEnd transitionend'; CSS.transitionEnd = 'webkitTransitionEnd transitionend';
} else { } else {
css.prefix = ''; CSS.prefix = '';
css.transform = 'transform'; CSS.transform = 'transform';
css.transition = 'transition'; CSS.transition = 'transition';
css.transitionEnd = 'transitionend'; CSS.transitionEnd = 'transitionend';
} }
export function transitionEndPromise(el:Element) { if (window.onanimationend === undefined && window.onwebkitanimationend !== undefined) {
CSS.animation = 'WebkitAnimation';
CSS.animationStart = 'webkitAnimationStart animationstart';
CSS.animationEnd = 'webkitAnimationEnd animationend';
} else {
CSS.animation = 'animation';
CSS.animationStart = 'animationstart';
CSS.animationEnd = 'animationend';
}
export function transitionEnd(el:Element) {
return cssPromise(el, CSS.transitionEnd);
}
export function animationStart(el:Element, animationName) {
return cssPromise(el, CSS.animationStart, animationName);
}
export function animationEnd(el:Element, animationName) {
return cssPromise(el, CSS.animationEnd, animationName);
}
function cssPromise(el:Element, eventNames, animationName) {
return new Promise(resolve => { return new Promise(resolve => {
css.transitionEnd.split(' ').forEach(eventName => { eventNames.split(' ').forEach(eventName => {
el.addEventListener(eventName, onTransitionEnd); el.addEventListener(eventName, onEvent);
}) })
function onTransitionEnd(ev) { function onEvent(ev) {
// Don't allow bubbled transitionend events if (ev.animationName && animationName) {
if (ev.target !== el) { // do not resolve if a bubbled up ev.animationName
// is not the same as the passed in animationName arg
if (ev.animationName !== animationName) {
return;
}
} else if (ev.target !== el) {
// do not resolve if the event's target element is not
// the same as the element the listener was added to
return; return;
} }
css.transitionEnd.split(' ').forEach(eventName => { ev.stopPropagation();
el.removeEventListener(css.transitionEnd, onTransitionEnd) eventNames.split(' ').forEach(eventName => {
el.removeEventListener(eventName, onEvent);
}) })
resolve(ev); resolve(ev);
} }